List of usage examples for java.lang Byte MAX_VALUE
byte MAX_VALUE
To view the source code for java.lang Byte MAX_VALUE.
Click Source Link
From source file:net.spfbl.core.Core.java
public static synchronized void setDeferTimeSOFTFAIL(int time) { if (time < 0 || time > Byte.MAX_VALUE) { Server.logError("invalid DEFER time for SOFTFAIL '" + time + "'."); } else {//from w w w .j ava 2 s . c om Core.DEFER_TIME_SOFTFAIL = (byte) time; } }
From source file:net.spfbl.dns.QueryDNS.java
public static void setConnectionLimit(int limit) { if (limit < 1 || limit > Byte.MAX_VALUE) { Server.logError("invalid DNS connection limit '" + limit + "'."); } else {//from ww w .j a v a2 s. c o m CONNECTION_LIMIT = (byte) limit; } }
From source file:net.spfbl.core.Core.java
public static synchronized void setDeferTimeYELLOW(int time) { if (time < 0 || time > Byte.MAX_VALUE) { Server.logError("invalid DEFER time for YELLOW '" + time + "'."); } else {/*from w w w. j a v a2s .co m*/ Core.DEFER_TIME_YELLOW = (byte) time; } }
From source file:de.bwravencl.controllerbuddy.gui.Main.java
public void handleOnScreenKeyboardModeChange() { if (scheduleOnScreenKeyboardModeSwitch) { for (final var buttonToModeActions : input.getProfile().getButtonToModeActionsMap().values()) for (final var buttonToModeAction : buttonToModeActions) if (OnScreenKeyboard.onScreenKeyboardMode.equals(buttonToModeAction.getMode(input))) { buttonToModeAction.doAction(input, Byte.MAX_VALUE); break; }/*from ww w . j a va2 s .c o m*/ scheduleOnScreenKeyboardModeSwitch = false; } }
From source file:org.apache.geode.internal.InternalDataSerializer.java
public static void writeDSFIDHeader(int dsfid, DataOutput out) throws IOException { if (dsfid == DataSerializableFixedID.ILLEGAL) { throw new IllegalStateException( LocalizedStrings.InternalDataSerializer_ATTEMPTED_TO_SERIALIZE_ILLEGAL_DSFID .toLocalizedString()); }/*from www. j a va 2 s . co m*/ if (dsfid <= Byte.MAX_VALUE && dsfid >= Byte.MIN_VALUE) { out.writeByte(DS_FIXED_ID_BYTE); out.writeByte(dsfid); } else if (dsfid <= Short.MAX_VALUE && dsfid >= Short.MIN_VALUE) { out.writeByte(DS_FIXED_ID_SHORT); out.writeShort(dsfid); } else { out.writeByte(DS_FIXED_ID_INT); out.writeInt(dsfid); } }
From source file:org.springframework.beans.BeanWrapperTests.java
@Test public void testSetNumberProperties() { NumberPropertyBean bean = new NumberPropertyBean(); BeanWrapper bw = new BeanWrapperImpl(bean); String byteValue = " " + Byte.MAX_VALUE + " "; String shortValue = " " + Short.MAX_VALUE + " "; String intValue = " " + Integer.MAX_VALUE + " "; String longValue = " " + Long.MAX_VALUE + " "; String floatValue = " " + Float.MAX_VALUE + " "; String doubleValue = " " + Double.MAX_VALUE + " "; bw.setPropertyValue("myPrimitiveByte", byteValue); bw.setPropertyValue("myByte", byteValue); bw.setPropertyValue("myPrimitiveShort", shortValue); bw.setPropertyValue("myShort", shortValue); bw.setPropertyValue("myPrimitiveInt", intValue); bw.setPropertyValue("myInteger", intValue); bw.setPropertyValue("myPrimitiveLong", longValue); bw.setPropertyValue("myLong", longValue); bw.setPropertyValue("myPrimitiveFloat", floatValue); bw.setPropertyValue("myFloat", floatValue); bw.setPropertyValue("myPrimitiveDouble", doubleValue); bw.setPropertyValue("myDouble", doubleValue); assertEquals(Byte.MAX_VALUE, bean.getMyPrimitiveByte()); assertEquals(Byte.MAX_VALUE, bean.getMyByte().byteValue()); assertEquals(Short.MAX_VALUE, bean.getMyPrimitiveShort()); assertEquals(Short.MAX_VALUE, bean.getMyShort().shortValue()); assertEquals(Integer.MAX_VALUE, bean.getMyPrimitiveInt()); assertEquals(Integer.MAX_VALUE, bean.getMyInteger().intValue()); assertEquals(Long.MAX_VALUE, bean.getMyPrimitiveLong()); assertEquals(Long.MAX_VALUE, bean.getMyLong().longValue()); assertEquals(Float.MAX_VALUE, bean.getMyPrimitiveFloat(), 0.001); assertEquals(Float.MAX_VALUE, bean.getMyFloat().floatValue(), 0.001); assertEquals(Double.MAX_VALUE, bean.getMyPrimitiveDouble(), 0.001); assertEquals(Double.MAX_VALUE, bean.getMyDouble().doubleValue(), 0.001); }
From source file:org.apache.geode.internal.InternalDataSerializer.java
/** * Data serializes an instance of a "user class" (that is, a class that can be handled by a * registered {@code DataSerializer}) to the given {@code DataOutput}. * * @return {@code true} if {@code o} was written to {@code out}. *//*from ww w. j a v a2 s . c o m*/ private static boolean writeUserObject(Object o, DataOutput out, boolean ensurePdxCompatibility) throws IOException { final Class<?> c = o.getClass(); final DataSerializer serializer = InternalDataSerializer.getSerializer(c); if (serializer != null) { int id = serializer.getId(); if (id != 0) { checkPdxCompatible(o, ensurePdxCompatibility); // id will be 0 if it is a WellKnowDS if (id <= Byte.MAX_VALUE && id >= Byte.MIN_VALUE) { out.writeByte(USER_CLASS); out.writeByte((byte) id); } else if (id <= Short.MAX_VALUE && id >= Short.MIN_VALUE) { out.writeByte(USER_CLASS_2); out.writeShort(id); } else { out.writeByte(USER_CLASS_4); out.writeInt(id); } } else { if (ensurePdxCompatibility) { if (!(serializer instanceof WellKnownPdxDS)) { checkPdxCompatible(o, ensurePdxCompatibility); } } } boolean toDataResult; try { toDataResult = serializer.toData(o, out); } catch (IOException io) { if (serializer instanceof WellKnownDS) { // this is not user code so throw IOException throw io; // see bug 44659 } else { // We no longer rethrow IOException here // because if user code throws an IOException we want // to create a ToDataException to report it as a problem // with the plugin code. throw new ToDataException("toData failed on DataSerializer with id=" + id + " for class " + c, io); } } catch (CancelException | ToDataException | GemFireRethrowable ex) { // Serializing a PDX can result in a cache closed exception. Just rethrow throw ex; } catch (VirtualMachineError err) { SystemFailure.initiateFailure(err); // If this ever returns, rethrow the error. We're poisoned // now, so don't let this thread continue. throw err; } catch (Throwable t) { // Whenever you catch Error or Throwable, you must also // catch VirtualMachineError (see above). However, there is // _still_ a possibility that you are dealing with a cascading // error condition, so you also need to check to see if the JVM // is still usable: SystemFailure.checkFailure(); throw new ToDataException("toData failed on DataSerializer with id=" + id + " for class " + c, t); } if (toDataResult) { return true; } else { throw new ToDataException( LocalizedStrings.DataSerializer_SERIALIZER_0_A_1_SAID_THAT_IT_COULD_SERIALIZE_AN_INSTANCE_OF_2_BUT_ITS_TODATA_METHOD_RETURNED_FALSE .toLocalizedString(serializer.getId(), serializer.getClass().getName(), o.getClass().getName())); } // Do byte[][] and Object[] here to fix bug 44060 } else if (o instanceof byte[][]) { byte[][] byteArrays = (byte[][]) o; out.writeByte(ARRAY_OF_BYTE_ARRAYS); writeArrayOfByteArrays(byteArrays, out); return true; } else if (o instanceof Object[]) { Object[] array = (Object[]) o; out.writeByte(OBJECT_ARRAY); writeObjectArray(array, out, ensurePdxCompatibility); return true; } else if (is662SerializationEnabled() && (o.getClass().isEnum()/* for bug 52271 */ || (o.getClass().getSuperclass() != null && o.getClass().getSuperclass().isEnum()))) { if (isPdxSerializationInProgress()) { writePdxEnum((Enum<?>) o, out); } else { checkPdxCompatible(o, ensurePdxCompatibility); writeGemFireEnum((Enum<?>) o, out); } return true; } else { PdxSerializer pdxSerializer = TypeRegistry.getPdxSerializer(); return pdxSerializer != null && writePdx(out, null, o, pdxSerializer); } }
From source file:net.sf.juffrou.reflect.spring.BeanWrapperTests.java
@Test public void testSetNumberProperties() { NumberPropertyBean bean = new NumberPropertyBean(); BeanWrapper bw = new JuffrouSpringBeanWrapper(bean); String byteValue = " " + Byte.MAX_VALUE + " "; String shortValue = " " + Short.MAX_VALUE + " "; String intValue = " " + Integer.MAX_VALUE + " "; String longValue = " " + Long.MAX_VALUE + " "; String floatValue = " " + Float.MAX_VALUE + " "; String doubleValue = " " + Double.MAX_VALUE + " "; bw.setPropertyValue("myPrimitiveByte", byteValue); bw.setPropertyValue("myByte", byteValue); bw.setPropertyValue("myPrimitiveShort", shortValue); bw.setPropertyValue("myShort", shortValue); bw.setPropertyValue("myPrimitiveInt", intValue); bw.setPropertyValue("myInteger", intValue); bw.setPropertyValue("myPrimitiveLong", longValue); bw.setPropertyValue("myLong", longValue); bw.setPropertyValue("myPrimitiveFloat", floatValue); bw.setPropertyValue("myFloat", floatValue); bw.setPropertyValue("myPrimitiveDouble", doubleValue); bw.setPropertyValue("myDouble", doubleValue); assertEquals(Byte.MAX_VALUE, bean.getMyPrimitiveByte()); assertEquals(Byte.MAX_VALUE, bean.getMyByte().byteValue()); assertEquals(Short.MAX_VALUE, bean.getMyPrimitiveShort()); assertEquals(Short.MAX_VALUE, bean.getMyShort().shortValue()); assertEquals(Integer.MAX_VALUE, bean.getMyPrimitiveInt()); assertEquals(Integer.MAX_VALUE, bean.getMyInteger().intValue()); assertEquals(Long.MAX_VALUE, bean.getMyPrimitiveLong()); assertEquals(Long.MAX_VALUE, bean.getMyLong().longValue()); assertEquals(Float.MAX_VALUE, bean.getMyPrimitiveFloat(), 0.001); assertEquals(Float.MAX_VALUE, bean.getMyFloat().floatValue(), 0.001); assertEquals(Double.MAX_VALUE, bean.getMyPrimitiveDouble(), 0.001); assertEquals(Double.MAX_VALUE, bean.getMyDouble().doubleValue(), 0.001); }
From source file:org.apache.geode.internal.InternalDataSerializer.java
public static void writeUserDataSerializableHeader(int classId, DataOutput out) throws IOException { if (classId <= Byte.MAX_VALUE && classId >= Byte.MIN_VALUE) { out.writeByte(USER_DATA_SERIALIZABLE); out.writeByte(classId);/*from w w w . j a va 2 s .c o m*/ } else if (classId <= Short.MAX_VALUE && classId >= Short.MIN_VALUE) { out.writeByte(USER_DATA_SERIALIZABLE_2); out.writeShort(classId); } else { out.writeByte(USER_DATA_SERIALIZABLE_4); out.writeInt(classId); } }
From source file:com.datatorrent.lib.appdata.gpo.GPOUtils.java
/** * Determines if the given value is within the range of the specified type. * @param type The type to determine the range of. Valid types can be byte or short. * @param val The value to check the range of. * @return True if the given int value is within the range of the specified type, false otherwise. *///from w w w. j a va2s . co m public static boolean insideRange(Type type, int val) { switch (type) { case BYTE: { return !(val < (int) Byte.MIN_VALUE || val > (int) Byte.MAX_VALUE); } case SHORT: { return !(val < (int) Short.MIN_VALUE || val > (int) Short.MAX_VALUE); } default: throw new UnsupportedOperationException("This operation is not supported for the type " + type); } }