List of usage examples for java.lang Short MIN_VALUE
short MIN_VALUE
To view the source code for java.lang Short MIN_VALUE.
Click Source Link
From source file:com.evolveum.midpoint.repo.sql.util.RUtil.java
public static Short toShort(Long l) { if (l == null) { return null; }//from w w w .j a v a 2 s . c o m if (l > Short.MAX_VALUE || l < Short.MIN_VALUE) { throw new IllegalArgumentException("Couldn't cast value to short " + l); } return l.shortValue(); }
From source file:org.lwes.EventTest.java
@Test public void testIntBounds() { final Event evt = createEvent(); evt.setEventName("Test"); evt.setByte("byte_min", Byte.MIN_VALUE); evt.setByte("byte_zero", (byte) 0); evt.setByte("byte_one", (byte) 1); evt.setByte("byte_max", Byte.MAX_VALUE); evt.setInt16("int16_min", Short.MIN_VALUE); evt.setInt16("int16_zero", (short) 0); evt.setInt16("int16_one", (short) 1); evt.setInt16("int16_max", Short.MAX_VALUE); evt.setInt32("int32_min", Integer.MIN_VALUE); evt.setInt32("int32_zero", 0); evt.setInt32("int32_one", 1); evt.setInt32("int32_max", Integer.MAX_VALUE); evt.setInt64("int64_min", Long.MIN_VALUE); evt.setInt64("int64_zero", 0); evt.setInt64("int64_one", 1); evt.setInt64("int64_max", Long.MAX_VALUE); evt.setUInt16("uint16_zero", 0); evt.setUInt16("uint16_one", 1); evt.setUInt16("uint16_max", 0xffff); evt.setUInt32("uint32_zero", 0); evt.setUInt32("uint32_one", 1); evt.setUInt32("uint32_max", 0xffffffffL); evt.setUInt64("uint64_zero", BigInteger.ZERO); evt.setUInt64("uint64_one", BigInteger.ONE); evt.setUInt64("uint64_max", BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE)); evt.setInt16Array("int16[]", new short[] { Short.MIN_VALUE, 0, 1, Short.MAX_VALUE }); evt.setInt32Array("int32[]", new int[] { Integer.MIN_VALUE, 0, 1, Integer.MAX_VALUE }); evt.setInt64Array("int64[]", new long[] { Long.MIN_VALUE, 0, 1, Long.MAX_VALUE }); evt.setUInt16Array("uint16[]", new int[] { 0, 1, 0xffff }); evt.setUInt32Array("uint32[]", new long[] { 0, 1, 0xffffffffL }); evt.setUInt64Array("uint64[]", new BigInteger[] { BigInteger.ZERO, BigInteger.ONE, BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE) }); evt.setUInt64Array("uint64[] prim", new long[] { 0, 1, -1 }); final Event evt2 = createEvent(); evt2.deserialize(evt.serialize());/*from w ww .ja v a 2 s . c o m*/ //assertEquals(evt, evt2); assertEquals(Byte.MIN_VALUE, evt.getByte("byte_min").byteValue()); assertEquals((byte) 0, evt.getByte("byte_zero").byteValue()); assertEquals((byte) 1, evt.getByte("byte_one").byteValue()); assertEquals(Byte.MAX_VALUE, evt.getByte("byte_max").byteValue()); assertEquals(Short.MIN_VALUE, evt.getInt16("int16_min").shortValue()); assertEquals((short) 0, evt.getInt16("int16_zero").shortValue()); assertEquals((short) 1, evt.getInt16("int16_one").shortValue()); assertEquals(Short.MAX_VALUE, evt.getInt16("int16_max").shortValue()); assertEquals(Integer.MIN_VALUE, evt.getInt32("int32_min").intValue()); assertEquals(0, evt.getInt32("int32_zero").intValue()); assertEquals(1, evt.getInt32("int32_one").intValue()); assertEquals(Integer.MAX_VALUE, evt.getInt32("int32_max").intValue()); assertEquals(Long.MIN_VALUE, evt.getInt64("int64_min").longValue()); assertEquals(0, evt.getInt64("int64_zero").longValue()); assertEquals(1, evt.getInt64("int64_one").longValue()); assertEquals(Long.MAX_VALUE, evt.getInt64("int64_max").longValue()); assertEquals(0, evt.getUInt16("uint16_zero").intValue()); assertEquals(1, evt.getUInt16("uint16_one").intValue()); assertEquals(0xffff, evt.getUInt16("uint16_max").intValue()); assertEquals(0, evt.getUInt32("uint32_zero").longValue()); assertEquals(1, evt.getUInt32("uint32_one").longValue()); assertEquals(0xffffffffL, evt.getUInt32("uint32_max").longValue()); assertEquals(BigInteger.ZERO, evt.getUInt64("uint64_zero")); assertEquals(BigInteger.ONE, evt.getUInt64("uint64_one")); assertEquals(BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE), evt.getUInt64("uint64_max")); assertArrayEquals(new short[] { Short.MIN_VALUE, 0, 1, Short.MAX_VALUE }, evt.getInt16Array("int16[]")); assertArrayEquals(new int[] { Integer.MIN_VALUE, 0, 1, Integer.MAX_VALUE }, evt.getInt32Array("int32[]")); assertArrayEquals(new long[] { Long.MIN_VALUE, 0, 1, Long.MAX_VALUE }, evt.getInt64Array("int64[]")); assertArrayEquals(new int[] { 0, 1, 0xffff }, evt.getUInt16Array("uint16[]")); assertArrayEquals(new long[] { 0, 1, 0xffffffffL }, evt.getUInt32Array("uint32[]")); assertArrayEquals(new BigInteger[] { BigInteger.ZERO, BigInteger.ONE, BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE) }, evt.getUInt64Array("uint64[]")); assertArrayEquals( new BigInteger[] { BigInteger.ZERO, BigInteger.ONE, BigInteger.ONE.shiftLeft(64).subtract(BigInteger.ONE) }, evt.getUInt64Array("uint64[] prim")); }
From source file:org.vertx.java.http.eventbusbridge.integration.MessagePublishTest.java
@Test public void testPublishingShortJson() throws IOException { final EventBusMessageType messageType = EventBusMessageType.Short; final Short sentShort = Short.MIN_VALUE; Map<String, String> expectations = createExpectations(generateUniqueAddress(), Base64.encodeAsString(sentShort.toString()), messageType); final AtomicInteger completedCount = new AtomicInteger(0); Handler<Message> messagePublishHandler = new MessagePublishHandler(sentShort, expectations, completedCount); registerListenersAndCheckForResponses(messagePublishHandler, expectations, NUMBER_OF_PUBLISH_HANDLERS, completedCount);//www . ja v a2s . c om String body = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_JSON, expectations); HttpRequestHelper.sendHttpPostRequest(url, body, (VertxInternal) vertx, Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_JSON); }
From source file:org.apache.axis2.databinding.utils.ConverterUtil.java
public static short convertToShort(String s) { if ((s == null) || s.equals("")) { return Short.MIN_VALUE; }/*from w w w.j av a 2 s. c om*/ if (s.startsWith("+")) { s = s.substring(1); } return Short.parseShort(s); }
From source file:uk.ac.diamond.scisoft.analysis.dataset.ShortDataset.java
private void allocateArray(final int... nshape) { if (data == null) { throw new IllegalStateException("Data buffer in dataset is null"); }// ww w. j a va 2 s . c o m if (dataShape != null) { // see if reserved space is sufficient if (isShapeInDataShape(nshape)) { shape = nshape; size = calcSize(shape); if (Arrays.equals(shape, dataShape)) { dataShape = null; // no reserved space } return; } } final IndexIterator iter = getIterator(); // not enough room so need to expand the allocated memory if (dataShape == null) dataShape = shape.clone(); expandDataShape(nshape); dataSize = calcSize(dataShape); final short[] ndata = createArray(dataSize); // PRIM_TYPE final int[] oshape = shape; // now this object has the new dimensions so specify them correctly shape = nshape; size = calcSize(nshape); // make sure that all the data is set to NaN, minimum value or false Arrays.fill(ndata, Short.MIN_VALUE); // CLASS_TYPE // DEFAULT_VAL // now copy the data back to the correct positions final IndexIterator niter = getSliceIterator(null, oshape, null); while (niter.hasNext() && iter.hasNext()) ndata[niter.index] = data[iter.index]; odata = data = ndata; // if fully expanded then reset the reserved space dimensions if (dataSize == size) { dataShape = null; } }
From source file:net.ymate.platform.core.lang.TreeObject.java
public TreeObject(Short s) { _object = s != null ? s : Short.MIN_VALUE; _type = TYPE_SHORT; }
From source file:au.org.ala.delta.editor.ui.image.ImageOverlayEditorController.java
@Action public void addAllUsualOverlays() { // We dont' want to base the overlay position on the menu click location in this case. if (_selection.getSelectedPoint() != null) { _selection.getSelectedPoint().setLocation(Integer.MIN_VALUE, Integer.MIN_VALUE); }//from w ww .j a va 2 s . c om Image image = _selection.getSelectedImage(); if (image.getSubject() instanceof Character) { Character character = (Character) image.getSubject(); Point origin = new Point(150, 300); if (image.getOverlay(OverlayType.OLFEATURE) == null) { ImageOverlay newOverlay = newOverlay(OverlayType.OLFEATURE); newOverlay.setX(origin.x); newOverlay.setY(origin.y); origin.x += 25; origin.y += 50; image.updateOverlay(newOverlay); } if (character.getCharacterType().isMultistate()) { addStateOverlays((MultiStateCharacter) character, origin); } else if (character.getCharacterType().isNumeric()) { if (image.getOverlay(OverlayType.OLENTER) == null) { ImageOverlay newOverlay = newOverlay(OverlayType.OLENTER); newOverlay.setX(400); newOverlay.setY(600); image.updateOverlay(newOverlay); } if (image.getOverlay(OverlayType.OLUNITS) == null && StringUtils.isNotEmpty(((NumericCharacter<?>) character).getUnits())) { ImageOverlay newOverlay = newOverlay(OverlayType.OLUNITS); newOverlay.setX(Short.MIN_VALUE); newOverlay.setY(Short.MIN_VALUE); image.updateOverlay(newOverlay); } } if (image.getOverlay(OverlayType.OLOK) == null) { newOverlay(OverlayType.OLOK); } if (image.getOverlay(OverlayType.OLCANCEL) == null) { newOverlay(OverlayType.OLCANCEL); } if (StringUtils.isNotEmpty(character.getNotes()) && image.getOverlay(OverlayType.OLNOTES) == null) { newOverlay(OverlayType.OLNOTES); } } }
From source file:org.cellprofiler.subimager.ImageWriterHandler.java
private byte[] convertImage(NDImage ndimage, PixelType pixelType, boolean toBigEndian) { double[] inputDouble = ndimage.getBuffer(); switch (pixelType) { case INT8:/*from w w w. j a v a2 s.c o m*/ return convertToIntegerType(inputDouble, Byte.MIN_VALUE, Byte.MAX_VALUE, Byte.SIZE / 8, toBigEndian); case UINT8: return convertToIntegerType(inputDouble, 0, (1L << Byte.SIZE) - 1, Byte.SIZE / 8, toBigEndian); case INT16: return convertToIntegerType(inputDouble, Short.MIN_VALUE, Short.MAX_VALUE, Short.SIZE / 8, toBigEndian); case UINT16: return convertToIntegerType(inputDouble, 0, (1L << Short.SIZE) - 1, Short.SIZE / 8, toBigEndian); case INT32: return convertToIntegerType(inputDouble, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.SIZE / 8, toBigEndian); case UINT32: return convertToIntegerType(inputDouble, 0, (1L << Integer.SIZE) - 1, Integer.SIZE / 8, toBigEndian); case FLOAT: { int bpp = Float.SIZE / 8; byte[] buffer = new byte[inputDouble.length * bpp]; for (int i = 0; i < inputDouble.length; i++) { DataTools.unpackBytes(Float.floatToIntBits((float) inputDouble[i]), buffer, i * bpp, bpp, !toBigEndian); } return buffer; } case DOUBLE: { int bpp = Double.SIZE / 8; byte[] buffer = new byte[inputDouble.length * bpp]; for (int i = 0; i < inputDouble.length; i++) { DataTools.unpackBytes(Double.doubleToLongBits(inputDouble[i]), buffer, i * bpp, bpp, !toBigEndian); } return buffer; } default: throw new UnsupportedOperationException("The pixel type, " + pixelType.getValue() + ", should have been explicitly handled by the caller and an error should have been reported to the web client."); } }
From source file:org.apache.pig.data.BinInterSedes.java
@Override @SuppressWarnings("unchecked") public void writeDatum(DataOutput out, Object val, byte type) throws IOException { switch (type) { case DataType.TUPLE: writeTuple(out, (Tuple) val); break;//from w w w.j a v a 2 s .c o m case DataType.BAG: writeBag(out, (DataBag) val); break; case DataType.MAP: { writeMap(out, (Map<String, Object>) val); break; } case DataType.INTERNALMAP: { out.writeByte(INTERNALMAP); Map<Object, Object> m = (Map<Object, Object>) val; out.writeInt(m.size()); Iterator<Map.Entry<Object, Object>> i = m.entrySet().iterator(); while (i.hasNext()) { Map.Entry<Object, Object> entry = i.next(); writeDatum(out, entry.getKey()); writeDatum(out, entry.getValue()); } break; } case DataType.INTEGER: int i = (Integer) val; if (i == 0) { out.writeByte(INTEGER_0); } else if (i == 1) { out.writeByte(INTEGER_1); } else if (Byte.MIN_VALUE <= i && i <= Byte.MAX_VALUE) { out.writeByte(INTEGER_INBYTE); out.writeByte(i); } else if (Short.MIN_VALUE <= i && i <= Short.MAX_VALUE) { out.writeByte(INTEGER_INSHORT); out.writeShort(i); } else { out.writeByte(INTEGER); out.writeInt(i); } break; case DataType.LONG: long lng = (Long) val; if (lng == 0) { out.writeByte(LONG_0); } else if (lng == 1) { out.writeByte(LONG_1); } else if (Byte.MIN_VALUE <= lng && lng <= Byte.MAX_VALUE) { out.writeByte(LONG_INBYTE); out.writeByte((int) lng); } else if (Short.MIN_VALUE <= lng && lng <= Short.MAX_VALUE) { out.writeByte(LONG_INSHORT); out.writeShort((int) lng); } else if (Integer.MIN_VALUE <= lng && lng <= Integer.MAX_VALUE) { out.writeByte(LONG_ININT); out.writeInt((int) lng); } else { out.writeByte(LONG); out.writeLong(lng); } break; case DataType.DATETIME: out.writeByte(DATETIME); out.writeLong(((DateTime) val).getMillis()); out.writeShort(((DateTime) val).getZone().getOffset((DateTime) val) / ONE_MINUTE); break; case DataType.FLOAT: out.writeByte(FLOAT); out.writeFloat((Float) val); break; case DataType.BIGINTEGER: out.writeByte(BIGINTEGER); writeBigInteger(out, (BigInteger) val); break; case DataType.BIGDECIMAL: out.writeByte(BIGDECIMAL); writeBigDecimal(out, (BigDecimal) val); break; case DataType.DOUBLE: out.writeByte(DOUBLE); out.writeDouble((Double) val); break; case DataType.BOOLEAN: if ((Boolean) val) out.writeByte(BOOLEAN_TRUE); else out.writeByte(BOOLEAN_FALSE); break; case DataType.BYTE: out.writeByte(BYTE); out.writeByte((Byte) val); break; case DataType.BYTEARRAY: { DataByteArray bytes = (DataByteArray) val; SedesHelper.writeBytes(out, bytes.mData); break; } case DataType.CHARARRAY: { SedesHelper.writeChararray(out, (String) val); break; } case DataType.GENERIC_WRITABLECOMPARABLE: out.writeByte(GENERIC_WRITABLECOMPARABLE); // store the class name, so we know the class to create on read writeDatum(out, val.getClass().getName()); Writable writable = (Writable) val; writable.write(out); break; case DataType.NULL: out.writeByte(NULL); break; default: throw new RuntimeException("Unexpected data type " + val.getClass().getName() + " found in stream. " + "Note only standard Pig type is supported when you output from UDF/LoadFunc"); } }
From source file:org.voltdb.TestParameterSet.java
public void testRoundtrip() throws IOException { Byte byteparam = new Byte((byte) 2); Short shortparam = new Short(Short.MAX_VALUE); Integer intparam = new Integer(Integer.MIN_VALUE); Long longparam = new Long(Long.MAX_VALUE - 1); Double doubleparam = new Double(Double.MAX_VALUE - 1); String stringparam = new String("ABCDE"); TimestampType dateparam = new TimestampType(); // current time BigDecimal bigdecimalparam = new BigDecimal(7654321).setScale(VoltDecimalHelper.kDefaultScale); VoltTable volttableparam = new VoltTable(new VoltTable.ColumnInfo("foo", VoltType.INTEGER)); volttableparam.addRow(Integer.MAX_VALUE); byte[] bytearray = new byte[] { (byte) 'f', (byte) 'o', (byte) 'o' }; short[] shortarray = new short[] { Short.MAX_VALUE, Short.MIN_VALUE, (short) 5 }; int[] intarray = new int[] { Integer.MAX_VALUE, Integer.MIN_VALUE, 5 }; double[] doublearray = new double[] { Double.MAX_VALUE, Double.MIN_VALUE, 5.5 }; String[] stringarray = new String[] { "ABC", "DEF", "HIJ" }; TimestampType[] datearray = new TimestampType[] { new TimestampType(), new TimestampType(), new TimestampType() }; BigDecimal bdtmp1 = new BigDecimal(7654321).setScale(VoltDecimalHelper.kDefaultScale); BigDecimal bdtmp2 = new BigDecimal(654321).setScale(VoltDecimalHelper.kDefaultScale); BigDecimal bdtmp3 = new BigDecimal(54321).setScale(VoltDecimalHelper.kDefaultScale); BigDecimal[] bigdecimalarray = new BigDecimal[] { bdtmp1, bdtmp2, bdtmp3 }; VoltTable vttmp1 = new VoltTable(new VoltTable.ColumnInfo("foo", VoltType.INTEGER), new VoltTable.ColumnInfo("bar", VoltType.STRING)); vttmp1.addRow(Integer.MAX_VALUE, "ry@nlikestheyankees"); VoltTable vttmp2 = new VoltTable(new VoltTable.ColumnInfo("bar", VoltType.INTEGER), new VoltTable.ColumnInfo("bar", VoltType.STRING)); vttmp2.addRow(Integer.MIN_VALUE, null); VoltTable vttmp3 = new VoltTable(new VoltTable.ColumnInfo("far", VoltType.INTEGER), new VoltTable.ColumnInfo("bar", VoltType.STRING)); vttmp3.addRow(new Integer(5), ""); VoltTable[] volttablearray = new VoltTable[] { vttmp1, vttmp2, vttmp3 }; assertTrue(bigdecimalparam.scale() == VoltDecimalHelper.kDefaultScale); assertTrue(bdtmp1.scale() == VoltDecimalHelper.kDefaultScale); assertTrue(bdtmp2.scale() == VoltDecimalHelper.kDefaultScale); assertTrue(bdtmp3.scale() == VoltDecimalHelper.kDefaultScale); ParameterSet pset = ParameterSet.fromArrayNoCopy(byteparam, shortparam, intparam, longparam, doubleparam, stringparam, dateparam, bigdecimalparam, volttableparam, bytearray, shortarray, intarray, doublearray, stringarray, datearray, bigdecimalarray, volttablearray); ByteBuffer buf = ByteBuffer.allocate(pset.getSerializedSize()); pset.flattenToBuffer(buf);/* w ww.ja va2 s. co m*/ buf.flip(); ParameterSet pset2 = ParameterSet.fromByteBuffer(buf); Object[] pset1array = pset.toArray(); Object[] pset2array = pset2.toArray(); assertTrue(Arrays.deepEquals(pset1array, pset2array)); }