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:com.sisrni.managedbean.UnidadMB.java

/** 
 * Metodo para guardar una instancia de 'Unidad' en la tabla 
 * correspondiente de la base de datos//from w  w w. j av a  2  s.  c o  m
 */
public void guardarUnidad() {
    String msg = "Unidad Almacenado Exitosamente!";
    try {
        unidad.setIdUnidad(Integer.MIN_VALUE);
        unidad.setIdOrganismo(organismoService.findById(organismo.getIdOrganismo()));
        unidadService.save(unidad);
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_INFO, "Guardado!!", msg));

    } catch (Exception e) {
        JsfUtil.addErrorMessage("Error al Guardar Unidad!");
        e.printStackTrace();
    }
    cargarUnidad();
}

From source file:com.googlecode.flyway.core.migration.SchemaVersion.java

public int compareTo(SchemaVersion o) {
    if (o == null) {
        return 1;
    }/*from  w  w w.j a v a  2 s  .c  o  m*/

    if (this == EMPTY) {
        return Integer.MIN_VALUE;
    }

    if (this == LATEST) {
        return Integer.MAX_VALUE;
    }

    if (o == EMPTY) {
        return Integer.MAX_VALUE;
    }

    if (o == LATEST) {
        return Integer.MIN_VALUE;
    }
    final String[] elements1 = getElements();
    final String[] elements2 = o.getElements();
    int smallestNumberOfElements = Math.min(elements1.length, elements2.length);
    for (int i = 0; i < smallestNumberOfElements; i++) {
        String element1 = elements1[i];
        String element2 = elements2[i];
        final int compared;
        if (StringUtils.isNumeric(element1) && StringUtils.isNumeric(element2)) {
            compared = Long.valueOf(element1).compareTo(Long.valueOf(element2));
        } else {
            compared = element1.compareTo(element2);
        }
        if (compared != 0) {
            return compared;
        }
    }

    final int lengthDifference = elements1.length - elements2.length;
    if (lengthDifference > 0 && onlyTrailingZeroes(elements1, smallestNumberOfElements)) {
        return 0;
    }
    if (lengthDifference < 0 && onlyTrailingZeroes(elements2, smallestNumberOfElements)) {
        return 0;
    }
    return lengthDifference;
}

From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.migration.FixCoreferenceFeatures.java

@Override
public int getPhase() {
    return Integer.MIN_VALUE;
}

From source file:com.loadsensing.app.XarxaGMaps.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gmaps);/*from   ww w  .  j a  v  a2  s.  com*/

    MapController mapController;
    MapView mapa;

    // Obtenemos una referencia al control MapView
    mapa = (MapView) findViewById(R.id.mapa);

    // Mostramos los controles de zoom sobre el mapa
    mapa.setBuiltInZoomControls(true);

    // Aadimos la capa de marcadores
    List<Overlay> mapOverlays;
    Drawable drawable;
    OverlayXarxa itemizedOverlay;

    mapOverlays = mapa.getOverlays();
    drawable = this.getResources().getDrawable(R.drawable.marker);
    itemizedOverlay = new OverlayXarxa(drawable, mapa);

    int minLatitude = Integer.MAX_VALUE;
    int maxLatitude = Integer.MIN_VALUE;
    int minLongitude = Integer.MAX_VALUE;
    int maxLongitude = Integer.MIN_VALUE;

    SharedPreferences settings = getSharedPreferences("LoadSensingApp", Context.MODE_PRIVATE);
    String address = SERVER_HOST + "?session=" + settings.getString("session", "");
    Log.d(DEB_TAG, "Requesting to " + address);

    try {
        String jsonString = JsonClient.connectString(address);

        // Convertim la resposta string a un JSONArray
        JSONArray llistaXarxesArray = new JSONArray(jsonString);

        // HashMap<String, String> xarxa = null;

        for (int i = 0; i < llistaXarxesArray.length(); i++) {
            // xarxa = new HashMap<String, String>();
            JSONObject xarxaJSON = new JSONObject();
            xarxaJSON = llistaXarxesArray.getJSONObject(i);

            float lat = Float.parseFloat(xarxaJSON.getString("Lat"));
            float lon = Float.parseFloat(xarxaJSON.getString("Lon"));
            GeoPoint point = new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6));

            int latInt = point.getLatitudeE6();
            int lonInt = point.getLongitudeE6();

            // Calculamos las coordenadas mximas y mnimas, para
            // posteriormente calcular el zoom y la posicin del mapa
            // centrado
            maxLatitude = Math.max(latInt, maxLatitude);
            minLatitude = Math.min(latInt, minLatitude);
            maxLongitude = Math.max(lonInt, maxLongitude);
            minLongitude = Math.min(lonInt, minLongitude);

            OverlayItem overlayitem = new OverlayItem(point,
                    xarxaJSON.getString("Nom") + " - " + xarxaJSON.getString("Sensors") + " sensors",
                    xarxaJSON.getString("Poblacio"));

            itemizedOverlay.addOverlay(overlayitem);
            mapOverlays.add(itemizedOverlay);
        }
        // setListAdapter(adapter);

    } catch (Exception e) {
        Log.d(DEB_TAG, "Error rebent xarxes");
    }

    // Definimos zoom y centramos el mapa
    mapController = mapa.getController();
    mapController.zoomToSpan(Math.abs(maxLatitude - minLatitude), Math.abs(maxLongitude - minLongitude));
    mapController.animateTo(new GeoPoint((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2));
}

From source file:org.elasticsearch.client.RestClientBuilderTests.java

public void testBuild() throws IOException {
    try {//w ww .ja  v a2 s  .c o m
        RestClient.builder((HttpHost[]) null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("hosts must not be null", e.getMessage());
    }

    try {
        RestClient.builder();
        fail("should have failed");
    } catch (IllegalArgumentException e) {
        assertEquals("no hosts provided", e.getMessage());
    }

    try {
        RestClient.builder(new HttpHost("localhost", 9200), null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("host cannot be null", e.getMessage());
    }

    try (RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build()) {
        assertNotNull(restClient);
    }

    try {
        RestClient.builder(new HttpHost("localhost", 9200))
                .setMaxRetryTimeoutMillis(randomIntBetween(Integer.MIN_VALUE, 0));
        fail("should have failed");
    } catch (IllegalArgumentException e) {
        assertEquals("maxRetryTimeoutMillis must be greater than 0", e.getMessage());
    }

    try {
        RestClient.builder(new HttpHost("localhost", 9200)).setDefaultHeaders(null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("defaultHeaders must not be null", e.getMessage());
    }

    try {
        RestClient.builder(new HttpHost("localhost", 9200)).setDefaultHeaders(new Header[] { null });
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("default header must not be null", e.getMessage());
    }

    try {
        RestClient.builder(new HttpHost("localhost", 9200)).setFailureListener(null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("failureListener must not be null", e.getMessage());
    }

    try {
        RestClient.builder(new HttpHost("localhost", 9200)).setHttpClientConfigCallback(null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("httpClientConfigCallback must not be null", e.getMessage());
    }

    try {
        RestClient.builder(new HttpHost("localhost", 9200)).setRequestConfigCallback(null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals("requestConfigCallback must not be null", e.getMessage());
    }

    int numNodes = randomIntBetween(1, 5);
    HttpHost[] hosts = new HttpHost[numNodes];
    for (int i = 0; i < numNodes; i++) {
        hosts[i] = new HttpHost("localhost", 9200 + i);
    }
    RestClientBuilder builder = RestClient.builder(hosts);
    if (randomBoolean()) {
        builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
            @Override
            public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                return httpClientBuilder;
            }
        });
    }
    if (randomBoolean()) {
        builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
            @Override
            public RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) {
                return requestConfigBuilder;
            }
        });
    }
    if (randomBoolean()) {
        int numHeaders = randomIntBetween(1, 5);
        Header[] headers = new Header[numHeaders];
        for (int i = 0; i < numHeaders; i++) {
            headers[i] = new BasicHeader("header" + i, "value");
        }
        builder.setDefaultHeaders(headers);
    }
    if (randomBoolean()) {
        builder.setMaxRetryTimeoutMillis(randomIntBetween(1, Integer.MAX_VALUE));
    }
    if (randomBoolean()) {
        String pathPrefix = (randomBoolean() ? "/" : "") + randomAsciiOfLengthBetween(2, 5);
        while (pathPrefix.length() < 20 && randomBoolean()) {
            pathPrefix += "/" + randomAsciiOfLengthBetween(3, 6);
        }
        builder.setPathPrefix(pathPrefix + (randomBoolean() ? "/" : ""));
    }
    try (RestClient restClient = builder.build()) {
        assertNotNull(restClient);
    }
}

From source file:io.github.karols.hocr4j.Bounds.java

/**
 * Returns the largest possible bounds.//from  w  w  w .  j av  a2  s  .c  om
 *
 * @return the entire plane
 */
public static Bounds getEntirePlane() {
    return new Bounds(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
}

From source file:com.luan.thermospy.server.core.ThermospyController.java

public void setTemperature(int temperature) {
    synchronized (myLock) {
        if (this.temperature != temperature) {
            String fromTemperature = this.temperature == Integer.MIN_VALUE ? "--"
                    : Integer.toString(this.temperature);
            String toTemperature = temperature == Integer.MIN_VALUE ? "--" : Integer.toString(temperature);
            Log.getLog().info("Temperature changed from " + fromTemperature + " to " + toTemperature);
            this.temperature = temperature;
        }//from w w w  . ja  va  2 s. c om

        if (this.logSession != null && this.temperature != Integer.MIN_VALUE) {
            org.hibernate.Session s = sessionFactory.openSession();
            Transaction tx = null;
            try {

                tx = s.beginTransaction();

                Temperatureentry entry = new Temperatureentry();
                entry.setTimestamp(new Date());
                entry.setFkSessionId(logSession.getId());
                entry.setTemperature((double) temperature);

                s.save(entry);
                tx.commit();

            } catch (Exception e) {

                if (tx != null)
                    tx.rollback();
                this.serverStatus = ServerStatus.INTERNAL_SERVER_ERROR;
            }
            s.close();

        }
    }
}

From source file:com.streamsets.pipeline.stage.it.AvroToParquetHiveIT.java

@Parameterized.Parameters(name = "type({0})")
public static Collection<Object[]> data() throws Exception {
    return Arrays.asList(new Object[][] {
            // Primitive types
            { "\"boolean\"", true, true, "BOOLEAN", Types.BOOLEAN, "0" },
            { "\"int\"", Integer.MIN_VALUE, Integer.MIN_VALUE, "INT", Types.INTEGER, "0" },
            { "\"long\"", Long.MAX_VALUE, Long.MAX_VALUE, "BIGINT", Types.BIGINT, "0" },
            // From some reason type is FLOAT, but returned object is double
            { "\"float\"", Float.NaN, Double.NaN, "FLOAT", Types.FLOAT, "0" },
            { "\"double\"", Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, "DOUBLE", Types.DOUBLE, "0" },
            { "\"bytes\"", ByteBuffer.wrap(new byte[] { (byte) 0x00, (byte) 0xFF }),
                    new byte[] { (byte) 0x00, (byte) 0xFF }, "BINARY", Types.BINARY, "1.0" },
            { "\"string\"", new Utf8("StreamSets"), "StreamSets", "STRING", Types.VARCHAR, "1.0" },

            // Complex types are skipped for now

            // Logical types
            { DECIMAL.toString(), ByteBuffer.wrap(new byte[] { (byte) 0x0F }), new BigDecimal("2"), "DECIMAL",
                    Types.DECIMAL, "0" },
            { DATE.toString(), 17039, new java.sql.Date(116, 7, 26), "DATE", Types.DATE, "1.2" }, });
}

From source file:com.memetro.android.notifications.NotificationUtils.java

/**
 * Gets the current registration id for application on GCM service.
 * <p>/*from  w w  w. ja va2  s  .  c o m*/
 * If result is empty, the registration has failed.
 *
 * @return registration id, or empty string if the registration is not
 * complete.
 */
public static String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGCMPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.length() == 0) {
        Log.v(TAG, "Registration not found.");
        return "";
    }
    // check if app was updated; if so, it must clear registration id to
    // avoid a race condition if GCM sends a message
    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion || isRegistrationExpired(context)) {
        Log.v(TAG, "App version changed or registration expired.");
        return "";
    }
    return registrationId;
}

From source file:InvertibleComparator.java

public int compare(Object o1, Object o2) {
    int result = this.comparator.compare(o1, o2);
    if (result != 0) {
        // Invert the order if it is a reverse sort.
        if (!this.ascending) {
            if (Integer.MIN_VALUE == result) {
                result = Integer.MAX_VALUE;
            } else {
                result *= -1;//from  w ww  .  jav a  2  s.c  o  m
            }
        }
        return result;
    }
    return 0;
}