Example usage for java.lang Short MIN_VALUE

List of usage examples for java.lang Short MIN_VALUE

Introduction

In this page you can find the example usage for java.lang Short MIN_VALUE.

Prototype

short MIN_VALUE

To view the source code for java.lang Short MIN_VALUE.

Click Source Link

Document

A constant holding the minimum value a short can have, -215.

Usage

From source file:com.repeatability.pdf.PDFTextStreamEngine.java

/**
 * This method was originally written by Ben Litchfield for PDFStreamEngine.
 *//*from   w w  w  .j ava2s  . co m*/
@Override
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode, Vector displacement)
        throws IOException {
    //
    // legacy calculations which were previously in PDFStreamEngine
    //

    PDGraphicsState state = getGraphicsState();
    Matrix ctm = state.getCurrentTransformationMatrix();
    float fontSize = state.getTextState().getFontSize();
    float horizontalScaling = state.getTextState().getHorizontalScaling() / 100f;
    Matrix textMatrix = getTextMatrix();

    BoundingBox bbox = font.getBoundingBox();
    if (bbox.getLowerLeftY() < Short.MIN_VALUE) {
        // PDFBOX-2158 and PDFBOX-3130
        // files by Salmat eSolutions / ClibPDF Library
        bbox.setLowerLeftY(-(bbox.getLowerLeftY() + 65536));
    }
    // 1/2 the bbox is used as the height todo: why?
    float glyphHeight = bbox.getHeight() / 2;

    // sometimes the bbox has very high values, but CapHeight is OK
    PDFontDescriptor fontDescriptor = font.getFontDescriptor();
    if (fontDescriptor != null) {
        float capHeight = fontDescriptor.getCapHeight();
        if (capHeight != 0 && capHeight < glyphHeight) {
            glyphHeight = capHeight;
        }
    }

    // transformPoint from glyph space -> text space
    float height;
    if (font instanceof PDType3Font) {
        height = font.getFontMatrix().transformPoint(0, glyphHeight).y;
    } else {
        height = glyphHeight / 1000;
    }

    float displacementX = displacement.getX();
    // the sorting algorithm is based on the width of the character. As the displacement
    // for vertical characters doesn't provide any suitable value for it, we have to 
    // calculate our own
    if (font.isVertical()) {
        displacementX = font.getWidth(code) / 1000;
        // there may be an additional scaling factor for true type fonts
        TrueTypeFont ttf = null;
        if (font instanceof PDTrueTypeFont) {
            ttf = ((PDTrueTypeFont) font).getTrueTypeFont();
        } else if (font instanceof PDType0Font) {
            PDCIDFont cidFont = ((PDType0Font) font).getDescendantFont();
            if (cidFont instanceof PDCIDFontType2) {
                ttf = ((PDCIDFontType2) cidFont).getTrueTypeFont();
            }
        }
        if (ttf != null && ttf.getUnitsPerEm() != 1000) {
            displacementX *= 1000f / ttf.getUnitsPerEm();
        }
    }
    // (modified) combined displacement, this is calculated *without* taking the character
    // spacing and word spacing into account, due to legacy code in TextStripper
    float tx = displacementX * fontSize * horizontalScaling;
    float ty = displacement.getY() * fontSize;

    // (modified) combined displacement matrix
    Matrix td = Matrix.getTranslateInstance(tx, ty);

    // (modified) text rendering matrix
    Matrix nextTextRenderingMatrix = td.multiply(textMatrix).multiply(ctm); // text space -> device space
    float nextX = nextTextRenderingMatrix.getTranslateX();
    float nextY = nextTextRenderingMatrix.getTranslateY();

    // (modified) width and height calculations
    float dxDisplay = nextX - textRenderingMatrix.getTranslateX();
    float dyDisplay = height * textRenderingMatrix.getScalingFactorY();

    //
    // start of the original method
    //

    // Note on variable names. There are three different units being used in this code.
    // Character sizes are given in glyph units, text locations are initially given in text
    // units, and we want to save the data in display units. The variable names should end with
    // Text or Disp to represent if the values are in text or disp units (no glyph units are
    // saved).

    float glyphSpaceToTextSpaceFactor = 1 / 1000f;
    if (font instanceof PDType3Font) {
        glyphSpaceToTextSpaceFactor = font.getFontMatrix().getScaleX();
    }

    float spaceWidthText = 0;
    try {
        // to avoid crash as described in PDFBOX-614, see what the space displacement should be
        spaceWidthText = font.getSpaceWidth() * glyphSpaceToTextSpaceFactor;
    } catch (Throwable exception) {
        LOG.warn(exception, exception);
    }

    if (spaceWidthText == 0) {
        spaceWidthText = font.getAverageFontWidth() * glyphSpaceToTextSpaceFactor;
        // the average space width appears to be higher than necessary so make it smaller
        spaceWidthText *= .80f;
    }
    if (spaceWidthText == 0) {
        spaceWidthText = 1.0f; // if could not find font, use a generic value
    }

    // the space width has to be transformed into display units
    float spaceWidthDisplay = spaceWidthText * textRenderingMatrix.getScalingFactorX();

    // use our additional glyph list for Unicode mapping
    unicode = font.toUnicode(code, glyphList);

    // when there is no Unicode mapping available, Acrobat simply coerces the character code
    // into Unicode, so we do the same. Subclasses of PDFStreamEngine don't necessarily want
    // this, which is why we leave it until this point in PDFTextStreamEngine.
    if (unicode == null) {
        if (font instanceof PDSimpleFont) {
            char c = (char) code;
            unicode = new String(new char[] { c });
        } else {
            // Acrobat doesn't seem to coerce composite font's character codes, instead it
            // skips them. See the "allah2.pdf" TestTextStripper file.
            return;
        }
    }

    // adjust for cropbox if needed
    Matrix translatedTextRenderingMatrix;
    if (translateMatrix == null) {
        translatedTextRenderingMatrix = textRenderingMatrix;
    } else {
        translatedTextRenderingMatrix = Matrix.concatenate(translateMatrix, textRenderingMatrix);
        nextX -= pageSize.getLowerLeftX();
        nextY -= pageSize.getLowerLeftY();
    }

    processTextPosition(new TextPosition(pageRotation, pageSize.getWidth(), pageSize.getHeight(),
            translatedTextRenderingMatrix, nextX, nextY, dyDisplay, dxDisplay, spaceWidthDisplay, unicode,
            new int[] { code }, font, fontSize, (int) (fontSize * textMatrix.getScalingFactorX())));
}

From source file:org.ballerinalang.stdlib.io.data.DataInputOutputTest.java

@DataProvider(name = "SignedLongValues")
public static Object[][] signedLongValues() {
    return new Object[][] { { 0, BIT_16 }, { 0, BIT_32 }, { 0, BIT_64 }, { -1, BIT_16 }, { -1, BIT_32 },
            { -1, BIT_64 }, { Short.MIN_VALUE, BIT_16 }, { Short.MIN_VALUE, BIT_32 },
            { Short.MIN_VALUE, BIT_64 }, { Short.MAX_VALUE, BIT_16 }, { Short.MAX_VALUE, BIT_32 },
            { Short.MAX_VALUE, BIT_64 }, { Integer.MIN_VALUE, BIT_32 }, { Integer.MIN_VALUE, BIT_64 },
            { Integer.MAX_VALUE, BIT_32 }, { Integer.MAX_VALUE, BIT_64 }, { Long.MIN_VALUE, BIT_64 },
            { Long.MAX_VALUE, BIT_64 } };
}

From source file:org.apache.pdfbox.text.LegacyPDFStreamEngine.java

/**
 * This method was originally written by Ben Litchfield for PDFStreamEngine.
 *//*from   w ww  . j  a  v a2s . c om*/
@Override
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode, Vector displacement)
        throws IOException {
    //
    // legacy calculations which were previously in PDFStreamEngine
    //
    //  DO NOT USE THIS CODE UNLESS YOU ARE WORKING WITH PDFTextStripper.
    //  THIS CODE IS DELIBERATELY INCORRECT
    //

    PDGraphicsState state = getGraphicsState();
    Matrix ctm = state.getCurrentTransformationMatrix();
    float fontSize = state.getTextState().getFontSize();
    float horizontalScaling = state.getTextState().getHorizontalScaling() / 100f;
    Matrix textMatrix = getTextMatrix();

    BoundingBox bbox = font.getBoundingBox();
    if (bbox.getLowerLeftY() < Short.MIN_VALUE) {
        // PDFBOX-2158 and PDFBOX-3130
        // files by Salmat eSolutions / ClibPDF Library
        bbox.setLowerLeftY(-(bbox.getLowerLeftY() + 65536));
    }
    // 1/2 the bbox is used as the height todo: why?
    float glyphHeight = bbox.getHeight() / 2;

    // sometimes the bbox has very high values, but CapHeight is OK
    PDFontDescriptor fontDescriptor = font.getFontDescriptor();
    if (fontDescriptor != null) {
        float capHeight = fontDescriptor.getCapHeight();
        if (capHeight != 0 && (capHeight < glyphHeight || glyphHeight == 0)) {
            glyphHeight = capHeight;
        }
    }

    // transformPoint from glyph space -> text space
    float height;
    if (font instanceof PDType3Font) {
        height = font.getFontMatrix().transformPoint(0, glyphHeight).y;
    } else {
        height = glyphHeight / 1000;
    }

    float displacementX = displacement.getX();
    // the sorting algorithm is based on the width of the character. As the displacement
    // for vertical characters doesn't provide any suitable value for it, we have to 
    // calculate our own
    if (font.isVertical()) {
        displacementX = font.getWidth(code) / 1000;
        // there may be an additional scaling factor for true type fonts
        TrueTypeFont ttf = null;
        if (font instanceof PDTrueTypeFont) {
            ttf = ((PDTrueTypeFont) font).getTrueTypeFont();
        } else if (font instanceof PDType0Font) {
            PDCIDFont cidFont = ((PDType0Font) font).getDescendantFont();
            if (cidFont instanceof PDCIDFontType2) {
                ttf = ((PDCIDFontType2) cidFont).getTrueTypeFont();
            }
        }
        if (ttf != null && ttf.getUnitsPerEm() != 1000) {
            displacementX *= 1000f / ttf.getUnitsPerEm();
        }
    }

    //
    // legacy calculations which were previously in PDFStreamEngine
    //
    //  DO NOT USE THIS CODE UNLESS YOU ARE WORKING WITH PDFTextStripper.
    //  THIS CODE IS DELIBERATELY INCORRECT
    //

    // (modified) combined displacement, this is calculated *without* taking the character
    // spacing and word spacing into account, due to legacy code in TextStripper
    float tx = displacementX * fontSize * horizontalScaling;
    float ty = displacement.getY() * fontSize;

    // (modified) combined displacement matrix
    Matrix td = Matrix.getTranslateInstance(tx, ty);

    // (modified) text rendering matrix
    Matrix nextTextRenderingMatrix = td.multiply(textMatrix).multiply(ctm); // text space -> device space
    float nextX = nextTextRenderingMatrix.getTranslateX();
    float nextY = nextTextRenderingMatrix.getTranslateY();

    // (modified) width and height calculations
    float dxDisplay = nextX - textRenderingMatrix.getTranslateX();
    float dyDisplay = height * textRenderingMatrix.getScalingFactorY();

    //
    // start of the original method
    //

    // Note on variable names. There are three different units being used in this code.
    // Character sizes are given in glyph units, text locations are initially given in text
    // units, and we want to save the data in display units. The variable names should end with
    // Text or Disp to represent if the values are in text or disp units (no glyph units are
    // saved).

    float glyphSpaceToTextSpaceFactor = 1 / 1000f;
    if (font instanceof PDType3Font) {
        glyphSpaceToTextSpaceFactor = font.getFontMatrix().getScaleX();
    }

    float spaceWidthText = 0;
    try {
        // to avoid crash as described in PDFBOX-614, see what the space displacement should be
        spaceWidthText = font.getSpaceWidth() * glyphSpaceToTextSpaceFactor;
    } catch (Throwable exception) {
        LOG.warn(exception, exception);
    }

    if (spaceWidthText == 0) {
        spaceWidthText = font.getAverageFontWidth() * glyphSpaceToTextSpaceFactor;
        // the average space width appears to be higher than necessary so make it smaller
        spaceWidthText *= .80f;
    }
    if (spaceWidthText == 0) {
        spaceWidthText = 1.0f; // if could not find font, use a generic value
    }

    // the space width has to be transformed into display units
    float spaceWidthDisplay = spaceWidthText * textRenderingMatrix.getScalingFactorX();

    // use our additional glyph list for Unicode mapping
    unicode = font.toUnicode(code, glyphList);

    // when there is no Unicode mapping available, Acrobat simply coerces the character code
    // into Unicode, so we do the same. Subclasses of PDFStreamEngine don't necessarily want
    // this, which is why we leave it until this point in PDFTextStreamEngine.
    if (unicode == null) {
        if (font instanceof PDSimpleFont) {
            char c = (char) code;
            unicode = new String(new char[] { c });
        } else {
            // Acrobat doesn't seem to coerce composite font's character codes, instead it
            // skips them. See the "allah2.pdf" TestTextStripper file.
            return;
        }
    }

    // adjust for cropbox if needed
    Matrix translatedTextRenderingMatrix;
    if (translateMatrix == null) {
        translatedTextRenderingMatrix = textRenderingMatrix;
    } else {
        translatedTextRenderingMatrix = Matrix.concatenate(translateMatrix, textRenderingMatrix);
        nextX -= pageSize.getLowerLeftX();
        nextY -= pageSize.getLowerLeftY();
    }

    processTextPosition(new TextPosition(pageRotation, pageSize.getWidth(), pageSize.getHeight(),
            translatedTextRenderingMatrix, nextX, nextY, Math.abs(dyDisplay), dxDisplay,
            Math.abs(spaceWidthDisplay), unicode, new int[] { code }, font, fontSize,
            (int) (fontSize * textMatrix.getScalingFactorX())));
}

From source file:streamflow.model.generator.RandomGenerator.java

public static Short randomShort() {
    return (short) (Short.MIN_VALUE + RandomUtils.nextInt(Short.MAX_VALUE - Short.MIN_VALUE));
}

From source file:org.diorite.utils.math.ShortRange.java

/**
 * Parses given string to range, string is valid range when contains 2 numbers (second greater than first) and splt char: <br>
 * " - ", " : ", " ; ", ", ", " ", ",", ";", ":", "-"
 *
 * @param string string to parse./* w w w .  j a  va  2s. c  om*/
 *
 * @return parsed range or null.
 */
public static ShortRange valueOf(String string) {
    if (string.isEmpty()) {
        return null;
    }
    String[] nums = null;
    int i = 0;
    final boolean firstMinus = string.charAt(0) == '-';
    if (firstMinus) {
        string = string.substring(1);
    }
    while ((i < ByteRange.SPLITS.length) && ((nums == null) || (nums.length != 2))) {
        nums = StringUtils.splitByWholeSeparator(string, ByteRange.SPLITS[i++], 2);
    }
    if ((nums == null) || (nums.length != 2)) {
        return null;
    }
    final Integer min = DioriteMathUtils.asInt(firstMinus ? ("-" + nums[0]) : nums[0]);
    if ((min == null) || (min < Short.MIN_VALUE)) {
        return null;
    }
    final Integer max = DioriteMathUtils.asInt(nums[1]);
    if ((max == null) || (max > Short.MAX_VALUE) || (min > max)) {
        return null;
    }
    return new ShortRange(min.shortValue(), max.shortValue());
}

From source file:it.geosolutions.jaiext.range.RangeTest.java

@BeforeClass
public static void initialSetup() {
    arrayB = new byte[] { 0, 1, 5, 50, 100 };
    arrayUS = new short[] { 0, 1, 5, 50, 100 };
    arrayS = new short[] { -10, 0, 5, 50, 100 };
    arrayI = new int[] { -10, 0, 5, 50, 100 };
    arrayF = new float[] { -10, 0, 5, 50, 100 };
    arrayD = new double[] { -10, 0, 5, 50, 100 };
    arrayL = new long[] { -10, 0, 5, 50, 100 };

    rangeB2bounds = RangeFactory.create((byte) 2, true, (byte) 60, true);
    rangeBpoint = RangeFactory.create(arrayB[2], true, arrayB[2], true);
    rangeU2bounds = RangeFactory.createU((short) 2, true, (short) 60, true);
    rangeUpoint = RangeFactory.createU(arrayUS[2], true, arrayUS[2], true);
    rangeS2bounds = RangeFactory.create((short) 1, true, (short) 60, true);
    rangeSpoint = RangeFactory.create(arrayS[2], true, arrayS[2], true);
    rangeI2bounds = RangeFactory.create(1, true, 60, true);
    rangeIpoint = RangeFactory.create(arrayI[2], true, arrayI[2], true);
    rangeF2bounds = RangeFactory.create(0.5f, true, 60.5f, true, false);
    rangeFpoint = RangeFactory.create(arrayF[2], true, arrayF[2], true, false);
    rangeD2bounds = RangeFactory.create(1.5d, true, 60.5d, true, false);
    rangeDpoint = RangeFactory.create(arrayD[2], true, arrayD[2], true, false);
    rangeL2bounds = RangeFactory.create(1L, true, 60L, true);
    rangeLpoint = RangeFactory.create(arrayL[2], true, arrayL[2], true);

    arrayBtest = new Byte[100];
    arrayStest = new Short[100];
    arrayItest = new Integer[100];
    arrayFtest = new Float[100];
    arrayDtest = new Double[100];

    // Random value creation for the various Ranges
    for (int j = 0; j < 100; j++) {
        double randomValue = Math.random();

        arrayBtest[j] = (byte) (randomValue * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
        arrayStest[j] = (short) (randomValue * (Short.MAX_VALUE - Short.MIN_VALUE) + Short.MIN_VALUE);
        arrayItest[j] = (int) (randomValue * (Integer.MAX_VALUE - Integer.MIN_VALUE) + Integer.MIN_VALUE);
        arrayFtest[j] = (float) (randomValue * (Float.MAX_VALUE - Float.MIN_VALUE) + Float.MIN_VALUE);
        arrayDtest[j] = (randomValue * (Double.MAX_VALUE - Double.MIN_VALUE) + Double.MIN_VALUE);
    }/* ww  w  .j  ava 2  s.c o  m*/

    // JAI tools Ranges
    rangeJTB = org.jaitools.numeric.Range.create((byte) 1, true, (byte) 60, true);
    rangeJTS = org.jaitools.numeric.Range.create((short) 1, true, (short) 60, true);
    rangeJTI = org.jaitools.numeric.Range.create(1, true, 60, true);
    rangeJTF = org.jaitools.numeric.Range.create(0.5f, true, 60.5f, true);
    rangeJTD = org.jaitools.numeric.Range.create(1.5d, true, 60.5d, true);
    // 1 point Ranges
    rangeJTBpoint = org.jaitools.numeric.Range.create((byte) 5, true, (byte) 5, true);
    rangeJTSpoint = org.jaitools.numeric.Range.create((short) 5, true, (short) 5, true);
    rangeJTIpoint = org.jaitools.numeric.Range.create(5, true, 5, true);
    rangeJTFpoint = org.jaitools.numeric.Range.create(5f, true, 5f, true);
    rangeJTDpoint = org.jaitools.numeric.Range.create(5d, true, 5d, true);

    // JAI Ranges
    rangeJAIB = new javax.media.jai.util.Range(Byte.class, (byte) 1, true, (byte) 60, true);
    rangeJAIS = new javax.media.jai.util.Range(Short.class, (short) 1, true, (short) 60, true);
    rangeJAII = new javax.media.jai.util.Range(Integer.class, 1, true, 60, true);
    rangeJAIF = new javax.media.jai.util.Range(Float.class, 0.5f, true, 60.5f, true);
    rangeJAID = new javax.media.jai.util.Range(Double.class, 1.5d, true, 60.5d, true);
    // 1 point Ranges
    rangeJAIBpoint = new javax.media.jai.util.Range(Byte.class, (byte) 5, true, (byte) 5, true);
    rangeJAISpoint = new javax.media.jai.util.Range(Short.class, (short) 5, true, (short) 5, true);
    rangeJAIIpoint = new javax.media.jai.util.Range(Integer.class, 5, true, 5, true);
    rangeJAIFpoint = new javax.media.jai.util.Range(Float.class, 5f, true, 5f, true);
    rangeJAIDpoint = new javax.media.jai.util.Range(Double.class, 5d, true, 5d, true);

    // Apache Common Ranges
    rangeCommonsB = new org.apache.commons.lang.math.IntRange((byte) 1, (byte) 60);
    rangeCommonsS = new org.apache.commons.lang.math.IntRange((short) 1, (short) 60);
    rangeCommonsI = new org.apache.commons.lang.math.IntRange(1, 60);
    rangeCommonsF = new org.apache.commons.lang.math.FloatRange(0.5f, 60.5f);
    rangeCommonsD = new org.apache.commons.lang.math.DoubleRange(1.5d, 60.5d);
    // 1 point Ranges
    rangeCommonsBpoint = new org.apache.commons.lang.math.IntRange(5);
    rangeCommonsSpoint = new org.apache.commons.lang.math.IntRange(5);
    rangeCommonsIpoint = new org.apache.commons.lang.math.IntRange(5);
    rangeCommonsFpoint = new org.apache.commons.lang.math.FloatRange(5f);
    rangeCommonsDpoint = new org.apache.commons.lang.math.DoubleRange(5d);

    //        // GeoTools Ranges
    //        rangeGeoToolsB = new org.geotools.util.NumberRange<Byte>(Byte.class, (byte) 1, (byte) 60);
    //        rangeGeoToolsS = new org.geotools.util.NumberRange<Short>(Short.class, (short) 1,
    //                (short) 60);
    //        rangeGeoToolsI = new org.geotools.util.NumberRange<Integer>(Integer.class, 1, 60);
    //        rangeGeoToolsF = new org.geotools.util.NumberRange<Float>(Float.class, 0.5f, 60.5f);
    //        rangeGeoToolsD = new org.geotools.util.NumberRange<Double>(Double.class, 1.5d, 60.5d);
    //        // 1 point Ranges
    //        rangeGeoToolsBpoint = new org.geotools.util.NumberRange<Byte>(Byte.class, (byte) 5,
    //                (byte) 5);
    //        rangeGeoToolsSpoint = new org.geotools.util.NumberRange<Short>(Short.class, (short) 5,
    //                (short) 5);
    //        rangeGeoToolsIpoint = new org.geotools.util.NumberRange<Integer>(Integer.class, 5, 5);
    //        rangeGeoToolsFpoint = new org.geotools.util.NumberRange<Float>(Float.class, 5f, 5f);
    //        rangeGeoToolsDpoint = new org.geotools.util.NumberRange<Double>(Double.class, 5d, 5d);

    //        // Guava Ranges
    //        rangeGuavaB = com.google.common.collect.Range.closed((byte) 1, (byte) 60);
    //        rangeGuavaS = com.google.common.collect.Range.closed((short) 1, (short) 60);
    //        rangeGuavaI = com.google.common.collect.Range.closed(1, 60);
    //        rangeGuavaF = com.google.common.collect.Range.closed(0.5f, 60.5f);
    //        rangeGuavaD = com.google.common.collect.Range.closed(1.5d, 60.5d);
    //        // 1 point Ranges
    //        rangeGuavaBpoint = com.google.common.collect.Range.singleton((byte) 5);
    //        rangeGuavaSpoint = com.google.common.collect.Range.singleton((short) 5);
    //        rangeGuavaIpoint = com.google.common.collect.Range.singleton(5);
    //        rangeGuavaFpoint = com.google.common.collect.Range.singleton(5f);
    //        rangeGuavaDpoint = com.google.common.collect.Range.singleton(5d);
}

From source file:org.ballerinalang.stdlib.io.data.DataInputOutputTest.java

@DataProvider(name = "SignedVarLongValues")
public static Object[][] signedVarLongValues() {
    return new Object[][] { { 0, 1 }, { 0, 1 }, { 0, 1 }, { -1, 1 }, { -1, 1 }, { -1, 1 },
            { Short.MIN_VALUE, 3 }, { Short.MIN_VALUE, 3 }, { Integer.MIN_VALUE, 5 }, { Integer.MIN_VALUE, 5 },
            { IOConstants.VAR_INT_MAX, 8 }, { IOConstants.VAR_INT_MIN, 8 } };
}

From source file:ddf.catalog.data.dynamic.impl.DynamicMetacardImplTest.java

@Test
public void testSetAttributeWithValues() throws Exception {
    metacard.setAttribute(STRING, "abc");
    assertEquals("abc", baseBean.get(STRING));

    metacard.setAttribute(BOOLEAN, true);
    assertEquals(true, baseBean.get(BOOLEAN));

    Date d = new Date(System.currentTimeMillis());
    metacard.setAttribute(DATE, d);// w  w  w. jav  a 2s . co m
    assertEquals(d, baseBean.get(DATE));

    metacard.setAttribute(SHORT, Short.MAX_VALUE);
    assertEquals(Short.MAX_VALUE, baseBean.get(SHORT));

    metacard.setAttribute(INTEGER, Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, baseBean.get(INTEGER));

    metacard.setAttribute(LONG, Long.MAX_VALUE);
    assertEquals(Long.MAX_VALUE, baseBean.get(LONG));

    metacard.setAttribute(FLOAT, Float.MAX_VALUE);
    assertEquals(Float.MAX_VALUE, baseBean.get(FLOAT));

    metacard.setAttribute(DOUBLE, Double.MAX_VALUE);
    assertEquals(Double.MAX_VALUE, baseBean.get(DOUBLE));

    Byte[] bytes = new Byte[] { 0x00, 0x01, 0x02, 0x03 };
    metacard.setAttribute(BINARY, bytes);
    assertEquals(bytes, baseBean.get(BINARY));

    metacard.setAttribute(XML, XML_STRING);
    assertEquals(XML_STRING, baseBean.get(XML));

    metacard.setAttribute(OBJECT, XML_STRING);
    assertEquals(XML_STRING, baseBean.get(OBJECT));

    List<Serializable> list = new ArrayList<>();
    list.add("123");
    list.add("234");
    list.add("345");
    metacard.setAttribute(STRING_LIST, list);
    assertEquals(list, baseBean.get(STRING_LIST));

    metacard.setAttribute(STRING_LIST, "456");
    Collection c = (Collection) baseBean.get(STRING_LIST);
    assertEquals(4, c.size());
    assertTrue(c.contains("456"));

    list.remove("123");
    metacard.setAttribute(STRING_LIST, list);
    c = (Collection) baseBean.get(STRING_LIST);
    assertEquals(3, c.size());
    assertTrue(c.contains("456"));
    assertFalse(c.contains("123"));

    metacard.setAttribute(SHORT, Short.MIN_VALUE);
    // this should take no action since auto-conversion fails - handled ConversionException
    metacard.setAttribute(SHORT, Long.MAX_VALUE);
    assertEquals(Short.MIN_VALUE, baseBean.get(SHORT));
}

From source file:org.jts.eclipse.conversion.cjsidl.ConversionUtil.java

/**
 * Used to fill a gap where a minimum value isn't specified in a range.
 * @param val - the current value, if there is one.
 * @param inputType - the input data type that the minimum should fit within
 * //from  w w w  .j  a  v  a 2s .  c om
 * @return - the original value if it exists, or the minimum value allowed within
 * the inputType specified.
 */
public static String getCountMin(String val, String inputType) {
    String result = val;
    if (result == null || result.isEmpty()) {
        if (inputType.equals("byte") || inputType.equals("int8")) {
            result = Byte.toString(Byte.MIN_VALUE);
        } else if (inputType.equals("short integer") || inputType.equals("int16")) {
            result = Short.toString(Short.MIN_VALUE);
        } else if (inputType.equals("integer") || inputType.equals("int32")) {
            result = Integer.toString(Integer.MIN_VALUE);
        } else if (inputType.equals("long integer") || inputType.equals("int64")) {
            result = Long.toString(Long.MIN_VALUE);
        } else if (inputType.equals("unsigned byte") || inputType.equals("uint8")) {
            result = "0";
        } else if (inputType.equals("unsigned short integer") || inputType.equals("uint16")) {
            result = "0";
        } else if (inputType.equals("unsigned integer") || inputType.equals("uint32")) {
            result = "0";
        } else if (inputType.equals("unsigned long integer") || inputType.equals("uint64")) {
            result = "0";
        } else if (inputType.equals("float") || inputType.equals("float")) {
            result = Float.toString(Float.MIN_VALUE);
        } else if (inputType.equals("long float") || inputType.equals("double")) {
            result = Double.toString(Double.MIN_VALUE);
        }
    }

    return result;
}

From source file:com.l2jfree.gameserver.geodata.pathfinding.geonodes.GeoPathFinding.java

private Node readNode(int gx, int gy, short z) {
    short node_x = getNodePos(gx);
    short node_y = getNodePos(gy);
    short regoffset = getRegionOffset(getRegionX(node_x), getRegionY(node_y));
    if (!pathNodesExist(regoffset))
        return null;
    short nbx = getNodeBlock(node_x);
    short nby = getNodeBlock(node_y);
    int idx = _pathNodesIndex.get(regoffset).get((nby << 8) + nbx);
    ByteBuffer pn = _pathNodes.get(regoffset);
    //reading//from  w  ww.java  2s.  c o m
    byte nodes = pn.get(idx++);
    int idx2 = 0; //create index to nearlest node by z
    short last_z = Short.MIN_VALUE;
    while (nodes > 0) {
        short node_z = pn.getShort(idx);
        if (Math.abs(last_z - z) > Math.abs(node_z - z)) {
            last_z = node_z;
            idx2 = idx + 2;
        }
        idx += 10; //short + 8 byte
        nodes--;
    }
    return new GeoNode(node_x, node_y, last_z, idx2);
}