类java.lang.Integer源码实例Demo

下面列出了怎么用java.lang.Integer的API类实例代码及写法,或者点击链接到github查看源代码。

private void wrapperPBEKeyTest(Provider p) throws InvalidKeySpecException,
        InvalidKeyException, NoSuchPaddingException,
        IllegalBlockSizeException, InvalidAlgorithmParameterException,
        NoSuchAlgorithmException {
    for (String alg : PBE_ALGORITHM_AR) {
        String baseAlgo = alg.split("/")[0].toUpperCase();
        // only run the tests on longer key lengths if unlimited version
        // of JCE jurisdiction policy files are installed

        if (Cipher.getMaxAllowedKeyLength(alg) < Integer.MAX_VALUE
                && (baseAlgo.endsWith("TRIPLEDES") || alg
                        .endsWith("AES_256"))) {
            out.println("keyStrength > 128 within " + alg
                    + " will not run under global policy");
            continue;
        }
        SecretKeyFactory skf = SecretKeyFactory.getInstance(baseAlgo, p);
        SecretKey key = skf.generateSecret(new PBEKeySpec("Secret Lover"
                .toCharArray()));
        wrapTest(alg, alg, key, key, Cipher.SECRET_KEY, true);
    }
}
 
源代码2 项目: openjdk-jdk9   文件: SpaceUtilizationCheck.java
public static void main(String[] args) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
       "-XX:+UnlockDiagnosticVMOptions",
       "-XX:SharedArchiveFile=./SpaceUtilizationCheck.jsa",
       "-Xshare:dump");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    String stdout = output.getStdout();
    ArrayList<String> utilization = findUtilization(stdout);

    if (utilization.size() != NUMBER_OF_CHECKED_SHARED_REGIONS )
        throw new RuntimeException("The output format of sharing summary has changed");

    for(String str : utilization) {
        int value = Integer.parseInt(str);
        if (value < MIN_UTILIZATION) {
            System.out.println(stdout);
            throw new RuntimeException("Utilization for one of the regions" +
                "is below a threshold of " + MIN_UTILIZATION + "%");
        }
    }
}
 
源代码3 项目: j2objc   文件: MaxFloatingPointTest.java
public void testDoubleNarrowing() {
  if (System.getProperty("os.arch").equals("armv7")) {
    return;
  }
  double dmin = Double.NEGATIVE_INFINITY;
  double dmax = Double.POSITIVE_INFINITY;
  assertEquals("dmin as long failed", Long.MIN_VALUE, (long) dmin);
  assertEquals("dmax as long failed", Long.MAX_VALUE, (long) dmax);
  assertEquals("dmin as int failed", Integer.MIN_VALUE, (int) dmin);
  assertEquals("dmax as int failed", Integer.MAX_VALUE, (int) dmax);
  assertEquals("dmin as char failed", Character.MIN_VALUE, (char) dmin);
  assertEquals("dmax as char failed", Character.MAX_VALUE, (char) dmax);

  assertEquals("dmin as short failed", 0, (short) dmin);
  assertEquals("dmax as short failed", -1, (short) dmax);
  assertEquals("dmin as byte failed", 0, (byte) dmin);
  assertEquals("dmax as byte failed", -1, (byte) dmax);
}
 
源代码4 项目: j2objc   文件: MaxFloatingPointTest.java
public void testFloatNarrowing() {
  if (System.getProperty("os.arch").equals("armv7")) {
    return;
  }
  float fmin = Float.NEGATIVE_INFINITY;
  float fmax = Float.POSITIVE_INFINITY;
  assertEquals("fmin as long failed", Long.MIN_VALUE, (long) fmin);
  assertEquals("fmax as long failed", Long.MAX_VALUE, (long) fmax);
  assertEquals("fmin as int failed", Integer.MIN_VALUE, (int) fmin);
  assertEquals("fmax as int failed", Integer.MAX_VALUE, (int) fmax);
  assertEquals("fmin as char failed", Character.MIN_VALUE, (char) fmin);
  assertEquals("fmax as char failed", Character.MAX_VALUE, (char) fmax);

  // Surprising values for shorts and bytes, but that's what's specified.
  assertEquals("fmin as short failed", 0, (short) fmin);
  assertEquals("fmax as short failed", -1, (short) fmax);
  assertEquals("fmin as byte failed", 0, (byte) fmin);
  assertEquals("fmax as byte failed", -1, (byte) fmax);
}
 
源代码5 项目: apollo-android   文件: ReviewInput.java
ReviewInput(int stars, Input<Integer> nullableIntFieldWithDefaultValue, Input<String> commentary,
    @NotNull ColorInput favoriteColor, Input<Episode> enumWithDefaultValue,
    @NotNull Episode nonNullableEnumWithDefaultValue, Input<Episode> nullableEnum,
    Input<List<Date>> listOfCustomScalar, Input<Date> customScalar,
    Input<List<Episode>> listOfEnums, Input<List<Integer>> listOfInt,
    Input<List<String>> listOfString, @NotNull List<String> listOfStringNonOptional,
    Input<List<ColorInput>> listOfInputTypes, Input<Boolean> booleanWithDefaultValue,
    Input<List<List<String>>> listOfListOfString, Input<List<List<Episode>>> listOfListOfEnum,
    Input<List<List<Date>>> listOfListOfCustom, Input<List<List<ColorInput>>> listOfListOfObject,
    Input<String> capitalizedField) {
  this.stars = stars;
  this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue;
  this.commentary = commentary;
  this.favoriteColor = favoriteColor;
  this.enumWithDefaultValue = enumWithDefaultValue;
  this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue;
  this.nullableEnum = nullableEnum;
  this.listOfCustomScalar = listOfCustomScalar;
  this.customScalar = customScalar;
  this.listOfEnums = listOfEnums;
  this.listOfInt = listOfInt;
  this.listOfString = listOfString;
  this.listOfStringNonOptional = listOfStringNonOptional;
  this.listOfInputTypes = listOfInputTypes;
  this.booleanWithDefaultValue = booleanWithDefaultValue;
  this.listOfListOfString = listOfListOfString;
  this.listOfListOfEnum = listOfListOfEnum;
  this.listOfListOfCustom = listOfListOfCustom;
  this.listOfListOfObject = listOfListOfObject;
  this.capitalizedField = capitalizedField;
}
 
源代码6 项目: apollo-android   文件: ReviewInput.java
ReviewInput(int stars, Input<Integer> nullableIntFieldWithDefaultValue, Input<String> commentary,
    @NotNull ColorInput favoriteColor, Input<Episode> enumWithDefaultValue,
    @NotNull Episode nonNullableEnumWithDefaultValue, Input<Episode> nullableEnum,
    Input<List<Object>> listOfCustomScalar, Input<Object> customScalar,
    Input<List<Episode>> listOfEnums, Input<List<Integer>> listOfInt,
    Input<List<String>> listOfString, @NotNull List<String> listOfStringNonOptional,
    Input<List<ColorInput>> listOfInputTypes, Input<Boolean> booleanWithDefaultValue,
    Input<List<List<String>>> listOfListOfString, Input<List<List<Episode>>> listOfListOfEnum,
    Input<List<List<Object>>> listOfListOfCustom,
    Input<List<List<ColorInput>>> listOfListOfObject, Input<String> capitalizedField) {
  this.stars = stars;
  this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue;
  this.commentary = commentary;
  this.favoriteColor = favoriteColor;
  this.enumWithDefaultValue = enumWithDefaultValue;
  this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue;
  this.nullableEnum = nullableEnum;
  this.listOfCustomScalar = listOfCustomScalar;
  this.customScalar = customScalar;
  this.listOfEnums = listOfEnums;
  this.listOfInt = listOfInt;
  this.listOfString = listOfString;
  this.listOfStringNonOptional = listOfStringNonOptional;
  this.listOfInputTypes = listOfInputTypes;
  this.booleanWithDefaultValue = booleanWithDefaultValue;
  this.listOfListOfString = listOfListOfString;
  this.listOfListOfEnum = listOfListOfEnum;
  this.listOfListOfCustom = listOfListOfCustom;
  this.listOfListOfObject = listOfListOfObject;
  this.capitalizedField = capitalizedField;
}
 
源代码7 项目: dragonwell8_jdk   文件: CollectionSupplier.java
/**
 * Create a Collection test case.
 *
 * @param name name of the test case
 * @param collection the modifiable test collection
 */
public TestCase(String name, Function<Collection<Integer>, C> supplier, C collection) {
    this.name = name;
    this.supplier = supplier;
    this.expected = Collections.unmodifiableList(
        Arrays.asList(collection.toArray(new Integer[0])));
    this.collection = collection;
}
 
源代码8 项目: mavlink   文件: RadioCalibration.java
/**
 * Rudder setpoints: nose left, center, nose right 
 */
@MavlinkFieldInfo(
        position = 3,
        unitSize = 2,
        arraySize = 3,
        description = "Rudder setpoints: nose left, center, nose right"
)
public final List<Integer> rudder() {
    return this.rudder;
}
 
源代码9 项目: tutorials   文件: ProcessUnderstandingUnitTest.java
@Test
public void givenSourceProgram_whenExecutedFromAnotherProgram_thenSourceProgramOutput3() throws IOException {
    Process process = Runtime.getRuntime()
        .exec("javac -cp src src\\main\\java\\com\\baeldung\\java9\\process\\OutputStreamExample.java");
    process = Runtime.getRuntime()
        .exec("java -cp  src/main/java com.baeldung.java9.process.OutputStreamExample");
    BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream()));
    int value = Integer.parseInt(output.readLine());
    assertEquals(3, value);            
}
 
源代码10 项目: TencentKona-8   文件: IPAddressName.java
private void parseIPv6(String name) throws IOException {

        int slashNdx = name.indexOf('/');
        if (slashNdx == -1) {
            address = InetAddress.getByName(name).getAddress();
        } else {
            address = new byte[32];
            byte[] base = InetAddress.getByName
                (name.substring(0, slashNdx)).getAddress();
            System.arraycopy(base, 0, address, 0, 16);

            // append a mask corresponding to the num of prefix bits specified
            int prefixLen = Integer.parseInt(name.substring(slashNdx+1));
            if (prefixLen < 0 || prefixLen > 128) {
                throw new IOException("IPv6Address prefix length (" +
                        prefixLen + ") in out of valid range [0,128]");
            }

            // create new bit array initialized to zeros
            BitArray bitArray = new BitArray(MASKSIZE * 8);

            // set all most significant bits up to prefix length
            for (int i = 0; i < prefixLen; i++)
                bitArray.set(i, true);
            byte[] maskArray = bitArray.toByteArray();

            // copy mask bytes into mask portion of address
            for (int i = 0; i < MASKSIZE; i++)
                address[MASKSIZE+i] = maskArray[i];
        }
    }
 
源代码11 项目: TencentKona-8   文件: CollectionSupplier.java
/**
 * Create a Collection test case.
 *
 * @param name name of the test case
 * @param collection the modifiable test collection
 */
public TestCase(String name, Function<Collection<Integer>, C> supplier, C collection) {
    this.name = name;
    this.supplier = supplier;
    this.expected = Collections.unmodifiableList(
        Arrays.asList(collection.toArray(new Integer[0])));
    this.collection = collection;
}
 
源代码12 项目: hottub   文件: IPAddressName.java
private void parseIPv6(String name) throws IOException {

        int slashNdx = name.indexOf('/');
        if (slashNdx == -1) {
            address = InetAddress.getByName(name).getAddress();
        } else {
            address = new byte[32];
            byte[] base = InetAddress.getByName
                (name.substring(0, slashNdx)).getAddress();
            System.arraycopy(base, 0, address, 0, 16);

            // append a mask corresponding to the num of prefix bits specified
            int prefixLen = Integer.parseInt(name.substring(slashNdx+1));
            if (prefixLen < 0 || prefixLen > 128) {
                throw new IOException("IPv6Address prefix length (" +
                        prefixLen + ") in out of valid range [0,128]");
            }

            // create new bit array initialized to zeros
            BitArray bitArray = new BitArray(MASKSIZE * 8);

            // set all most significant bits up to prefix length
            for (int i = 0; i < prefixLen; i++)
                bitArray.set(i, true);
            byte[] maskArray = bitArray.toByteArray();

            // copy mask bytes into mask portion of address
            for (int i = 0; i < MASKSIZE; i++)
                address[MASKSIZE+i] = maskArray[i];
        }
    }
 
源代码13 项目: dataenum   文件: PrimitiveValue.java
@Override
public int hashCode() {
  int result = 0;
  result = result * 31 + Integer.valueOf(this.param1).hashCode();
  result = result * 31 + Boolean.valueOf(this.param2).hashCode();
  result = result * 31 + Float.valueOf(this.param3).hashCode();
  return result * 31 + Double.valueOf(this.param4).hashCode();
}
 
源代码14 项目: mavlink   文件: EscTelemetry1To4.java
/**
 * Current. 
 */
@MavlinkFieldInfo(
        position = 3,
        unitSize = 2,
        arraySize = 4,
        description = "Current."
)
public final List<Integer> current() {
    return this.current;
}
 
源代码15 项目: j2objc   文件: MaxFloatingPointTest.java
public void testFloatConversions() {
  if (System.getProperty("os.arch").equals("armv7")) {
    return;
  }
  Float maxFloat = Float.MAX_VALUE;
  assertEquals(Integer.MAX_VALUE, maxFloat.intValue());
  assertEquals(Long.MAX_VALUE, maxFloat.longValue());
}
 
源代码16 项目: openjdk-8   文件: IPAddressName.java
private void parseIPv6(String name) throws IOException {

        int slashNdx = name.indexOf('/');
        if (slashNdx == -1) {
            address = InetAddress.getByName(name).getAddress();
        } else {
            address = new byte[32];
            byte[] base = InetAddress.getByName
                (name.substring(0, slashNdx)).getAddress();
            System.arraycopy(base, 0, address, 0, 16);

            // append a mask corresponding to the num of prefix bits specified
            int prefixLen = Integer.parseInt(name.substring(slashNdx+1));
            if (prefixLen > 128)
                throw new IOException("IPv6Address prefix is longer than 128");

            // create new bit array initialized to zeros
            BitArray bitArray = new BitArray(MASKSIZE * 8);

            // set all most significant bits up to prefix length
            for (int i = 0; i < prefixLen; i++)
                bitArray.set(i, true);
            byte[] maskArray = bitArray.toByteArray();

            // copy mask bytes into mask portion of address
            for (int i = 0; i < MASKSIZE; i++)
                address[MASKSIZE+i] = maskArray[i];
        }
    }
 
public static void bind(@NonNull NullableExampleActivity target, @NonNull Bundle source) {
  if (source.containsKey("name")) {
    target.name = (String) source.getString("name");
  }
  if (source.containsKey("number")) {
    target.number = (Integer) source.getInt("number");
  }
}
 
源代码18 项目: peapod   文件: Programmer$Impl.java
public void setExperience(Integer years) {
    if (years == null) {
        v.property("experience").remove();
    } else {
        v.property("experience", years);
    }
}
 
源代码19 项目: public   文件: MinistryOfInformationTests.java
private List<House> generateHouses(String idPrefix,
                                   String phonePrefix,
                                   int numHouses) {
    List<House> houses = new ArrayList<House>();
    for (int i = 0; i < numHouses; ++i) {
        houses.add(new House(idPrefix + Integer.toString(i),
                            i,
                            phonePrefix + Integer.toString(i)));
    }
    return houses;
}
 
public static TestClassBundledGCM unbundle(Bundle bundle, Gson gson) {
    return new AutoValue_TestClassBundledGCM(
            bundle,
            Byte.parseByte(bundle.getString("some_byte")),
            Boolean.parseBoolean(bundle.getString("some_boolean")),
            Short.parseShort(bundle.getString("some_short")),
            Integer.parseInt(bundle.getString("some_int")),
            Long.parseLong(bundle.getString("some_long")),
            bundle.getString("some_char").charAt(0),
            Float.parseFloat(bundle.getString("some_float")),
            Double.parseDouble(bundle.getString("some_double")),
            bundle.getString("some_string"),
            bundle.getString("some_char_sequence"),
            gson.fromJson(bundle.getString("some_parcelable"), Parcelable.class),
            gson.fromJson(bundle.getString("some_parcelable_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<Parcelable>>(){}.getType()),
            gson.fromJson(bundle.getString("some_parcelable_sparse_array"), new com.google.common.reflect.TypeToken<android.util.SparseArray<Parcelable>>(){}.getType()),
            gson.fromJson(bundle.getString("some_serializable"), Serializable.class),
            gson.fromJson(bundle.getString("some_integer_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<Integer>>(){}.getType()),
            gson.fromJson(bundle.getString("some_string_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<String>>(){}.getType()),
            gson.fromJson(bundle.getString("some_char_sequence_array_list"), new com.google.common.reflect.TypeToken<java.util.ArrayList<CharSequence>>(){}.getType()),
            toPrimitive(gson.fromJson(bundle.getString("some_byte_array"), Byte[].class)),
            toPrimitive(gson.fromJson(bundle.getString("some_short_array"), Short[].class)),
            toPrimitive(gson.fromJson(bundle.getString("some_char_array"), Character[].class)),
            toPrimitive(gson.fromJson(bundle.getString("some_float_array"), Float[].class)),
            gson.fromJson(bundle.getString("some_unknown_object"), new com.google.common.reflect.TypeToken<UnknownObject>(){}.getType()),
            gson.fromJson(bundle.getString("some_unknown_object_list"), new com.google.common.reflect.TypeToken<ArrayList<UnknownObject>>(){}.getType()),
            gson.fromJson(bundle.getString("test_enum"), new com.google.common.reflect.TypeToken<TestEnum>(){}.getType()));
}
 
源代码21 项目: Android-POS   文件: DataBinderMapperImpl.java
@Override
public int getLayoutId(String tag) {
  if (tag == null) {
    return 0;
  }
  Integer tmpVal = InnerLayoutIdLookup.sKeys.get(tag);
  return tmpVal == null ? 0 : tmpVal;
}
 
源代码22 项目: mavlink   文件: AqEscTelemetry.java
private AqEscTelemetry(long timeBootMs, int seq, int numMotors, int numInSeq, byte[] escid,
        List<Integer> statusAge, byte[] dataVersion, List<Long> data0, List<Long> data1) {
    this.timeBootMs = timeBootMs;
    this.seq = seq;
    this.numMotors = numMotors;
    this.numInSeq = numInSeq;
    this.escid = escid;
    this.statusAge = statusAge;
    this.dataVersion = dataVersion;
    this.data0 = data0;
    this.data1 = data1;
}
 
源代码23 项目: SVGAPlayer-Android   文件: MovieParams.java
public MovieParams(Float viewBoxWidth, Float viewBoxHeight, Integer fps, Integer frames, ByteString unknownFields) {
  super(ADAPTER, unknownFields);
  this.viewBoxWidth = viewBoxWidth;
  this.viewBoxHeight = viewBoxHeight;
  this.fps = fps;
  this.frames = frames;
}
 
源代码24 项目: jdk8u-jdk   文件: CollectionSupplier.java
/**
 * Create a Collection test case.
 *
 * @param name name of the test case
 * @param collection the modifiable test collection
 */
public TestCase(String name, Function<Collection<Integer>, C> supplier, C collection) {
    this.name = name;
    this.supplier = supplier;
    this.expected = Collections.unmodifiableList(
        Arrays.asList(collection.toArray(new Integer[0])));
    this.collection = collection;
}
 
源代码25 项目: mavlink   文件: TerrainData.java
/**
 * Terrain data MSL 
 */
@MavlinkFieldInfo(
        position = 5,
        unitSize = 2,
        arraySize = 16,
        signed = true,
        description = "Terrain data MSL"
)
public final List<Integer> data() {
    return this.data;
}
 
/**
 * {@inheritDoc}
 */
@Override
@NonNull
public BoxedTypesMethodsConstructor mapFromCursor(@NonNull StorIOContentResolver storIOContentResolver, @NonNull Cursor cursor) {

    Boolean field1 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
        field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    }
    Short field2 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
        field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    }
    Integer field3 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
        field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    }
    Long field4 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
        field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    }
    Float field5 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
        field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    }
    Double field6 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
        field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    }

    BoxedTypesMethodsConstructor object = new BoxedTypesMethodsConstructor(field1, field2, field3, field4, field5, field6);

    return object;
}
 
源代码27 项目: dataenum   文件: EfficientEquals.java
@Override
public int hashCode() {
  int result = 0;
  result = result * 31 + Integer.valueOf(this.param1).hashCode();
  result = result * 31 + this.param2.hashCode();
  result = result * 31 + this.param3.hashCode();
  return result * 31 + Double.valueOf(this.param4).hashCode();
}
 
源代码28 项目: mavlink   文件: SmartBatteryStatus.java
/**
 * Individual cell voltages. Batteries with more 16 cells can use the cell_offset field to 
 * specify the cell offset for the array specified in the current message . Index values above the 
 * valid cell count for this battery should have the UINT16_MAX value. 
 */
@MavlinkFieldInfo(
        position = 9,
        unitSize = 2,
        arraySize = 16,
        description = "Individual cell voltages. Batteries with more 16 cells can use the cell_offset field to specify the cell offset for the array specified in the current message . Index values above the valid cell count for this battery should have the UINT16_MAX value."
)
public final List<Integer> voltages() {
    return this.voltages;
}
 
源代码29 项目: JavaSCR   文件: safeArithmetic.java
private static int safeAdd(int left, int right) throws ArithmeticException {
	if (right > 0 ? left > Integer.MAX_VALUE - right
			: left < Integer.MIN_VALUE - right) {
		throw new ArithmeticException("Integer overflow"); //$NON-NLS-1$
	}
	return left + right;
}
 
源代码30 项目: mavlink   文件: EscTelemetry5To8.java
/**
 * Voltage. 
 */
@MavlinkFieldInfo(
        position = 2,
        unitSize = 2,
        arraySize = 4,
        description = "Voltage."
)
public final List<Integer> voltage() {
    return this.voltage;
}
 
 类所在包
 同包方法