本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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
}
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}