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


Java Arrays.copyOf方法代码示例

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


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

示例1: renameType

import java.util.Arrays; //导入方法依赖的package包/类
private static TypeParameter renameType(TypeParameter type, ReplacerClassMap map) {
	
	ObjectType superclassType = type.getClassBound();
	if (superclassType != null) {
		ObjectType newSuperclassType = renameType(superclassType, map);
		if (newSuperclassType != null) {
			superclassType = newSuperclassType;
		}
	}
	
	ObjectType[] interfaceTypes = type.getInterfaceBound();
	if (interfaceTypes != null) {
		interfaceTypes = Arrays.copyOf(interfaceTypes, interfaceTypes.length);
		for (int i=0; i<interfaceTypes.length; i++) {
			ObjectType newInterfaceType = renameType(interfaceTypes[i], map);
			if (newInterfaceType != null) {
				interfaceTypes[i] = newInterfaceType;
			}
		}
	}
	
	return new TypeParameter(type.getName(), superclassType, interfaceTypes);
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:24,代码来源:ClassRenamer.java

示例2: interpretWithArguments

import java.util.Arrays; //导入方法依赖的package包/类
@Hidden
@DontInline
/** Interpretively invoke this form on the given arguments. */
Object interpretWithArguments(Object... argumentValues) throws Throwable {
    if (TRACE_INTERPRETER)
        return interpretWithArgumentsTracing(argumentValues);
    checkInvocationCounter();
    assert(arityCheck(argumentValues));
    Object[] values = Arrays.copyOf(argumentValues, names.length);
    for (int i = argumentValues.length; i < values.length; i++) {
        values[i] = interpretName(names[i], values);
    }
    Object rv = (result < 0) ? null : values[result];
    assert(resultCheck(argumentValues, rv));
    return rv;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:LambdaForm.java

示例3: getType

import java.util.Arrays; //导入方法依赖的package包/类
public static BiomeType getType(String name)
{
    name = name.toUpperCase();

    for (BiomeType t : values())
    {
        if (t.name().equals(name)) return t;
    }

    BiomeType ret = EnumHelper.addEnum(BiomeType.class, name, new Class[0], new Object[0]);

    if (ret.ordinal() >= biomes.length)
    {
        biomes = Arrays.copyOf(biomes, ret.ordinal() + 1);
    }

    return ret;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:BiomeManager.java

示例4: Permission

import java.util.Arrays; //导入方法依赖的package包/类
public Permission(byte[] actionCodes) {
  if (actionCodes != null) {
    Action acts[] = new Action[actionCodes.length];
    int j = 0;
    for (int i=0; i<actionCodes.length; i++) {
      byte b = actionCodes[i];
      Action a = ACTION_BY_CODE.get(b);
      if (a == null) {
        LOG.error("Ignoring unknown action code '"+
            Bytes.toStringBinary(new byte[]{b})+"'");
        continue;
      }
      acts[j++] = a;
    }
    this.actions = Arrays.copyOf(acts, j);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:Permission.java

示例5: grow

import java.util.Arrays; //导入方法依赖的package包/类
@Override
void grow(int newBlockCount) {
  super.grow(newBlockCount);
  ramBytesUsed -= RamUsageEstimator.sizeOf(averages);
  averages = Arrays.copyOf(averages, newBlockCount);
  ramBytesUsed += RamUsageEstimator.sizeOf(averages);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:MonotonicLongValues.java

示例6: ensureCapacity

import java.util.Arrays; //导入方法依赖的package包/类
private void ensureCapacity() {
    if (mSize <= mData.length) {
        return;
    }
    int newCap = mData.length;
    while (mSize > newCap) {
        newCap = newCap * 3 / 2 + 1;
    }
    mData = Arrays.copyOf(mData, newCap);
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:11,代码来源:IntArray.java

示例7: throwWithNull

import java.util.Arrays; //导入方法依赖的package包/类
@Test
public void throwWithNull() {
    for (int i=0; i<args.length; i++) {
        Object[] temp = Arrays.copyOf(args, args.length);
        temp[i] = null;
        try {
            sink.accept(temp);
            fail(String.format("Expected NullPointerException for argument %d of test case %s", i, name));
        }
        catch (NullPointerException e) {
            // Success
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:NullArgsTestCase.java

示例8: clone

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Returns a clone of this {@code SerialJavaObject}.
 *
 * @return  a clone of this SerialJavaObject
 */

public Object clone() {
    try {
        SerialJavaObject sjo = (SerialJavaObject) super.clone();
        sjo.fields = Arrays.copyOf(fields, fields.length);
        if (chain != null)
            sjo.chain = new Vector<>(chain);
        return sjo;
    } catch (CloneNotSupportedException ex) {
        // this shouldn't happen, since we are Cloneable
        throw new InternalError();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:SerialJavaObject.java

示例9: xor

import java.util.Arrays; //导入方法依赖的package包/类
public static byte[] xor(byte[] a, byte[] b) {
    byte[] local_a = Arrays.copyOf(a, a.length);
    byte[] local_b = Arrays.copyOf(b, b.length);
    Preconditions.checkArgument(local_a.length == local_b.length,
            "The arrays should have the same size. |a| = [" + local_a.length + "], |b| = [" + local_b.length + "]");
    byte[] result = new byte[local_a.length];
    for (int i = 0; i < local_a.length; i++) {
        result[i] = (byte) (local_a[i] ^ local_b[i]);
    }
    return result;
}
 
开发者ID:republique-et-canton-de-geneve,项目名称:chvote-protocol-poc,代码行数:12,代码来源:ByteArrayUtils.java

示例10: getMobileInfoString

import java.util.Arrays; //导入方法依赖的package包/类
@SuppressLint({"StringFormatMatches", "StringFormatInvalid"})
private String getMobileInfoString(Context c) {
    c.getPackageManager();
    String apksign = "error getting package signature";
    String version = "error getting version";
    try {
        @SuppressLint("PackageManagerGetSignatures") Signature raw = c.getPackageManager().getPackageInfo(c.getPackageName(), PackageManager.GET_SIGNATURES).signatures[0];
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        X509Certificate cert = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(raw.toByteArray()));
        MessageDigest md = MessageDigest.getInstance("SHA-1");
        byte[] der = cert.getEncoded();
        md.update(der);
        byte[] digest = md.digest();
        if (Arrays.equals(digest, VpnStatus.officalkey)) apksign = c.getString(R.string.official_build);
        else if (Arrays.equals(digest, VpnStatus.officaldebugkey)) apksign = c.getString(R.string.debug_build);
        else if (Arrays.equals(digest, VpnStatus.amazonkey)) apksign = "amazon version";
        else if (Arrays.equals(digest, VpnStatus.fdroidkey)) apksign = "F-Droid built and signed version";
        else apksign = c.getString(R.string.built_by, cert.getSubjectX500Principal().getName());
        PackageInfo packageinfo = c.getPackageManager().getPackageInfo(c.getPackageName(), 0);
        version = packageinfo.versionName;
    } catch (PackageManager.NameNotFoundException | CertificateException |
            NoSuchAlgorithmException ignored) {
    }
    Object[] argsext = Arrays.copyOf(mArgs, mArgs.length);
    argsext[argsext.length - 1] = apksign;
    argsext[argsext.length - 2] = version;
    return c.getString(R.string.mobile_info, argsext);
}
 
开发者ID:akashdeepsingh9988,项目名称:Cybernet-VPN,代码行数:29,代码来源:LogItem.java

示例11: getElementAttributeListeners

import java.util.Arrays; //导入方法依赖的package包/类
@Override
public synchronized ElementAttributeListener[] getElementAttributeListeners(
        long qualifierId) {
    if (qualifierId == -1l)
        return Arrays.copyOf(nullElementAttributeListeners,
                nullElementAttributeListeners.length);

    ElementAttributeListener[] listeners = elementAttributeListeners
            .get(qualifierId);
    if (listeners == null)
        return new ElementAttributeListener[]{};
    return Arrays.copyOf(listeners, listeners.length);

}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:15,代码来源:AbstractEngine.java

示例12: setColumns

import java.util.Arrays; //导入方法依赖的package包/类
public void setColumns(String [] cols) {
  if (null == cols) {
    this.columns = null;
  } else {
    this.columns = Arrays.copyOf(cols, cols.length);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:8,代码来源:SqoopOptions.java

示例13: asArrayOfType

import java.util.Arrays; //导入方法依赖的package包/类
@Override
public Object asArrayOfType(final Class<?> componentType) {
    if (componentType == long.class) {
        final int len = (int)length();
        return array.length == len ? array.clone() : Arrays.copyOf(array, len);
    }
    return super.asArrayOfType(componentType);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:LongArrayData.java

示例14: modify

import java.util.Arrays; //导入方法依赖的package包/类
@Override
public Action[] modify(Action[] actions, final TableEditor tableEditor) {
    actions = Arrays.copyOf(actions, actions.length + 1);
    actions[actions.length - 1] = new AbstractAction("Log", new ImageIcon(
            getClass().getResource("/com/ramussoft/client/log/log.png"))) {

        /**
         *
         */
        private static final long serialVersionUID = 8698485078278772063L;

        {
            putValue(LONG_DESCRIPTION, getString("EventType.qualifierLog"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            GUIFramework framework = tableEditor.getFramework();

            Engine engine = framework.getEngine();
            long qId = StandardAttributesPlugin
                    .getTableQualifierForAttribute(engine,
                            tableEditor.getAttribute()).getId();

            List<Event> events = ((ILog) engine).getEventsWithParams(
                    new String[]{EngineLogExtension.QUALIFIER_ID},
                    new Object[]{qId}, 750);

            List<Event> events2 = new ArrayList<Event>();

            Attribute attribute = StandardAttributesPlugin
                    .getTableElementIdAttribute(engine);

            Element el = tableEditor.getElement();

            for (Event event : events) {
                Long elementId = (Long) event.getAttribute("element_id");
                if (elementId != null) {
                    Element element = engine.getElement(elementId);
                    if (element != null) {
                        Long l = (Long) engine.getAttribute(element,
                                attribute);
                        if (l != null && l.equals(el.getId()))
                            events2.add(event);
                    }
                }
            }

            ElementLogDialog dialog = new ElementLogDialog(events2, engine);
            dialog.setSize(800, 600);
            dialog.setLocationRelativeTo(null);
            dialog.setTitle(getString("EventType.qualifierLog"));

            Options.loadOptions(dialog);

            dialog.setVisible(true);

            Options.saveOptions(dialog);
        }
    };
    return actions;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:63,代码来源:LogPlugin.java

示例15: setEras

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Sets era strings. For example: "AD" and "BC".
 * @param newEras the new era strings.
 */
public void setEras(String[] newEras) {
    eras = Arrays.copyOf(newEras, newEras.length);
    cachedHashCode = 0;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:DateFormatSymbols.java


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