當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。