Example usage for java.lang Integer MIN_VALUE

List of usage examples for java.lang Integer MIN_VALUE

Introduction

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

Prototype

int MIN_VALUE

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

Click Source Link

Document

A constant holding the minimum value an int can have, -231.

Usage

From source file:de.tu_berlin.dima.oligos.db.HistogramHandler.java

public HistogramHandler(final String keyColumnName, final String valueColumnName, final Parser<T> parser) {
    this.keyColumnName = keyColumnName;
    this.valColumnName = valueColumnName;
    this.parser = parser;
    this.keyColumnIndex = Integer.MIN_VALUE;
    this.valColumnIndex = Integer.MIN_VALUE;
}

From source file:com.opensymphony.xwork2.conversion.impl.StringConverterTest.java

public void testIntegerToStringConversionPL() throws Exception {
    // given/* www  .  j a  va2  s .c o  m*/
    StringConverter converter = new StringConverter();
    Map<String, Object> context = new HashMap<>();
    context.put(ActionContext.LOCALE, new Locale("pl", "PL"));

    // when
    Object value = converter.convertValue(context, null, null, null, Integer.MIN_VALUE, null);

    // then
    assertEquals("" + Integer.MIN_VALUE, value);
}

From source file:com.ewcms.web.pubsub.ProgressSender.java

private Integer getSiteId(String path) {
    String[] s = StringUtils.split(path, "/");
    String value = s[s.length - 1];
    try {/*  w w w  . ja  va2s. c o  m*/
        return Integer.valueOf(value);
    } catch (Exception e) {
        return Integer.MIN_VALUE;
    }
}

From source file:com.itemanalysis.psychometrics.scaling.PercentileRank.java

public PercentileRank() {
    this(Integer.MIN_VALUE, Integer.MAX_VALUE);
}

From source file:net.sf.sprockets.database.Cursors.java

/**
 * Get the int value in the first row and column.
 *
 * @param close true to close the cursor or false to leave it open
 * @return {@link Integer#MIN_VALUE} if the cursor is empty
 * @since 2.5.0/*from  ww  w  .  j  a v a  2 s  .com*/
 */
public static int firstInt(Cursor cursor, boolean close) {
    int i = cursor.moveToFirst() ? cursor.getInt(0) : Integer.MIN_VALUE;
    close(cursor, close);
    return i;
}

From source file:io.github.benas.jpopulator.randomizers.validation.MaxValueRandomizer.java

/**
 * Generate a random value for the given type.
 *
 * @param type the type for which a random value will be generated
 * @param maxValue the maximum threshold for the generated value
 * @return a random value (lower than maxValue) for the given type or null if the type is not supported
 *//* www. jav a 2s  . c  o  m*/
public static Object getRandomValue(final Class type, final long maxValue) {

    if (type.equals(Byte.TYPE) || type.equals(Byte.class)) {
        return (byte) randomDataGenerator.nextLong(Byte.MIN_VALUE, maxValue);
    }
    if (type.equals(Short.TYPE) || type.equals(Short.class)) {
        return (short) randomDataGenerator.nextLong(Short.MIN_VALUE, maxValue);
    }
    if (type.equals(Integer.TYPE) || type.equals(Integer.class)) {
        return (int) randomDataGenerator.nextLong(Integer.MIN_VALUE, maxValue);
    }
    if (type.equals(Long.TYPE) || type.equals(Long.class)) {
        return randomDataGenerator.nextLong(Long.MIN_VALUE, maxValue);
    }
    if (type.equals(BigInteger.class)) {
        return new BigInteger(String.valueOf(randomDataGenerator.nextLong(Long.MIN_VALUE, maxValue)));
    }
    if (type.equals(BigDecimal.class)) {
        return new BigDecimal(randomDataGenerator.nextLong(Long.MIN_VALUE, maxValue));
    }
    return null;
}

From source file:edu.byu.nlp.util.AbstractCounter.java

/** {@inheritDoc} */
@Override/*w w w.  j  a v a2 s.c o  m*/
public E argMax(RandomGenerator rnd) {
    E argMax = null;
    int maxCount = Integer.MIN_VALUE;
    int tieCount = 0;
    for (Entry<E, Integer> entry : entrySet()) {
        if (entry.getValue() > maxCount) {
            maxCount = entry.getValue();
            argMax = entry.getKey();
            tieCount = 0;
        } else if (entry.getValue() == maxCount) {
            // To break ties, we have to randomly select one of the ties. The following algorithm is reservoir
            // sampling with a reservoir of size 1.
            int u = rnd.nextInt(++tieCount + 1);
            if (u == 0) {
                argMax = entry.getKey();
            }
        }
    }
    return argMax;
}

From source file:NumberUtils.java

/**
 * Convert the given number into an instance of the given target class.
 * @param number the number to convert/*from w  w  w.jav  a 2s . c  om*/
 * @param targetClass the target class to convert to
 * @return the converted number
 * @throws IllegalArgumentException if the target class is not supported
 * (i.e. not a standard Number subclass as included in the JDK)
 * @see java.lang.Byte
 * @see java.lang.Short
 * @see java.lang.Integer
 * @see java.lang.Long
 * @see java.math.BigInteger
 * @see java.lang.Float
 * @see java.lang.Double
 * @see java.math.BigDecimal
 */
public static Number convertNumberToTargetClass(Number number, Class targetClass)
        throws IllegalArgumentException {

    if (targetClass.isInstance(number)) {
        return number;
    } else if (targetClass.equals(Byte.class)) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Byte(number.byteValue());
    } else if (targetClass.equals(Short.class)) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Short(number.shortValue());
    } else if (targetClass.equals(Integer.class)) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Integer(number.intValue());
    } else if (targetClass.equals(Long.class)) {
        return new Long(number.longValue());
    } else if (targetClass.equals(Float.class)) {
        return new Float(number.floatValue());
    } else if (targetClass.equals(Double.class)) {
        return new Double(number.doubleValue());
    } else if (targetClass.equals(BigInteger.class)) {
        return BigInteger.valueOf(number.longValue());
    } else if (targetClass.equals(BigDecimal.class)) {
        // using BigDecimal(String) here, to avoid unpredictability of BigDecimal(double)
        // (see BigDecimal javadoc for details)
        return new BigDecimal(number.toString());
    } else {
        throw new IllegalArgumentException("Could not convert number [" + number + "] of type ["
                + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]");
    }
}

From source file:jp.co.ipublishing.aeskit.notification.gcm.GCMRegister.java

/**
 * GCMID??/*from   w w w .  j  av  a2 s  . c  om*/
 *
 * @param context 
 * @return GCMID??????????????
 */
@NonNull
private static String getRegistrationId(@NonNull Context context) {
    final SharedPreferences prefs = getPreferences(context);
    final String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.isEmpty()) {
        Log.i(TAG, "Registration not found.");
        return "";
    }

    final int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    final int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        Log.i(TAG, "App version changed.");
        return "";
    }
    return registrationId;
}

From source file:edu.psu.citeseerx.disambiguation.CsxDisambiguation.java

public static void createBlocks(ListableBeanFactory factory) throws Exception {
    String dirpath = "data/csauthors/blocks";

    DataSource dataSource = (DataSource) factory.getBean("csxDataSource");

    PreparedStatement st = dataSource.getConnection().prepareStatement("SELECT * FROM authors",
            ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    st.setFetchSize(Integer.MIN_VALUE);
    ResultSet rs = st.executeQuery();

    initDirectories(dirpath);/*  www . j a  v  a2 s.c o m*/

    CsxAuthorFilter filter = (CsxAuthorFilter) factory.getBean("csxAuthorFilter");
    //new CsxAuthorFilter("data/csauthors/name_stopwords.txt");
    BufferedWriter skip = new BufferedWriter(new FileWriter("skip.txt"));

    int count = 0;
    Map<String, List<String>> blocks = new HashMap<String, List<String>>();
    while (rs.next()) {
        count++;
        if ((count % 10000) == 0)
            System.out.println("#Auth:" + count);
        String rsname = rs.getString("name");
        if (!filter.isStopword(rsname) && !filter.isInstitute(rsname) && !filter.isPosition(rsname)) {

            CsxAuthor auth = new CsxAuthor(rs);
            String lname = auth.getLastName();
            String fname = auth.getFirstName();

            if ((lname != null) && (fname != null)) {
                if ((lname.charAt(0) >= 'A') && (lname.charAt(0) <= 'Z') && (fname.charAt(0) >= 'A')
                        && (fname.charAt(0) <= 'Z') && !((fname.length() == 1) && (lname.length() == 1))
                        && !(lname.matches(".*/.*"))) {

                    String l_init = lname.substring(0, 1).toUpperCase();
                    String f_init = fname.substring(0, 1).toUpperCase();
                    String key = l_init + f_init + "/" + lname.toLowerCase() + "_" + f_init.toLowerCase()
                            + ".txt";

                    List<String> list;
                    if (!blocks.containsKey(key)) {
                        list = new ArrayList<String>();
                        blocks.put(key, list);
                    } else {
                        list = blocks.get(key);
                    }
                    list.add(auth.getId());
                } else {
                    skip.write("SKIP: [" + rsname + "]\n");
                }
            }
        }
    }
    skip.close();

    for (String key : blocks.keySet()) {
        List<String> aids = blocks.get(key);
        // only care about cluster with more than one document
        if (aids.size() > 1) {
            BufferedWriter out = new BufferedWriter(new FileWriter(dirpath + "/" + key));
            for (String aid : aids) {
                out.write(aid + "\n");
            }
            out.close();
        }
    }
}