Example usage for java.lang Integer intValue

List of usage examples for java.lang Integer intValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public int intValue() 

Source Link

Document

Returns the value of this Integer as an int .

Usage

From source file:com.crs4.roodin.bayesian.SessionsLogger.java

/**
 * @param input//from w w w .j  a  v a 2  s.co m
 * @return int[][] matrix from JSONArray 
 */
private int[][] convertToMatrix(JSONArray input) {

    try {
        int rows = input.length();
        int cols = ((JSONArray) input.get(0)).length();

        Log.i("barred: ", "" + rows + "-" + cols);

        int[][] output = new int[rows][cols];

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                JSONArray e = (JSONArray) input.get(i);
                Integer value = e.getInt(j);
                output[i][j] = value.intValue();
            }
        }
        return output;

    } catch (JSONException e1) {
        Log.e("ERRORE", "in convertJSONArray " + e1.getMessage());
        return null;
    }
}

From source file:eu.stratosphere.api.common.operators.util.FieldList.java

public boolean isValidSubset(FieldList list) {
    if (list.size() > size()) {
        return false;
    }//from   w  w  w  .j a v  a  2  s . c om
    final List<Integer> myList = get();
    final List<Integer> theirList = list.get();
    for (int i = 0; i < theirList.size(); i++) {
        Integer myInt = myList.get(i);
        Integer theirInt = theirList.get(i);
        if (myInt.intValue() != theirInt.intValue()) {
            return false;
        }
    }
    return true;
}

From source file:com.salmon.security.xacml.demo.springmvc.rest.HTTPPopulatorsTest.java

@Test
public void testAllDataIsErased() {

    this.createOneDriver();
    this.createOneVehicle();

    ResponseEntity<Integer> entity = this.eraseAllData();

    Integer totalItemsDeleted = entity.getBody();
    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertEquals(2, totalItemsDeleted.intValue());
}

From source file:com.opengamma.transport.TaxonomyGatheringFudgeMessageSenderTest.java

@Test(timeOut = 10000)
public void taxonomyGathering() throws IOException, InterruptedException {
    File tmpFile = File.createTempFile("TaxonomyGatheringFudgeMessageSenderTest_taxonomyGathering",
            ".properties");
    FileUtils.forceDelete(tmpFile);/*from w  w  w .  j  a v a 2  s  . c  o  m*/
    FileUtils.forceDeleteOnExit(tmpFile);

    FudgeContext context = new FudgeContext();
    CollectingFudgeMessageReceiver collectingReceiver = new CollectingFudgeMessageReceiver();
    ByteArrayFudgeMessageReceiver fudgeReceiver = new ByteArrayFudgeMessageReceiver(collectingReceiver);
    DirectInvocationByteArrayMessageSender byteArraySender = new DirectInvocationByteArrayMessageSender(
            fudgeReceiver);
    ByteArrayFudgeMessageSender fudgeSender = new ByteArrayFudgeMessageSender(byteArraySender, context);
    TaxonomyGatheringFudgeMessageSender gatheringSender = new TaxonomyGatheringFudgeMessageSender(fudgeSender,
            tmpFile.getAbsolutePath(), context, 1000L);

    MutableFudgeMsg msg1 = context.newMessage();
    msg1.add("name1", 1);
    msg1.add("name2", 1);
    msg1.add("name3", 1);
    msg1.add("name1", 1);
    MutableFudgeMsg msg2 = context.newMessage();
    msg1.add("name4", msg2);
    msg2.add(14, 1);
    msg2.add("name5", "foo");

    gatheringSender.send(msg1);

    assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name1"));
    assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name2"));
    assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name3"));
    assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name4"));
    assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name5"));
    assertEquals(5, gatheringSender.getCurrentTaxonomy().size());

    Properties props = new Properties();
    gatheringSender.waitForNextWrite();
    InputStream is = new FileInputStream(tmpFile);
    props.load(new BufferedInputStream(is));
    is.close();

    for (Map.Entry<Object, Object> propEntry : props.entrySet()) {
        Integer ordinal = gatheringSender.getCurrentTaxonomy().get(propEntry.getValue());
        assertEquals(ordinal.intValue(), Integer.parseInt((String) propEntry.getKey()));
    }
    assertEquals(5, props.size());
}

From source file:com.rramos.bigdata.utils.GenericUDFSha2.java

@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    checkArgsSize(arguments, 2, 2);//from   w  w  w.j  a  v  a  2  s . c  o m

    checkArgPrimitive(arguments, 0);
    checkArgPrimitive(arguments, 1);

    // the function should support both string and binary input types
    checkArgGroups(arguments, 0, inputTypes, STRING_GROUP, BINARY_GROUP);
    checkArgGroups(arguments, 1, inputTypes, NUMERIC_GROUP);

    if (PrimitiveObjectInspectorUtils.getPrimitiveGrouping(inputTypes[0]) == STRING_GROUP) {
        obtainStringConverter(arguments, 0, inputTypes, converters);
        isStr = true;
    } else {
        GenericUDFParamUtils.obtainBinaryConverter(arguments, 0, inputTypes, converters);
        isStr = false;
    }

    if (arguments[1] instanceof ConstantObjectInspector) {
        Integer lenObj = getConstantIntValue(arguments, 1);
        if (lenObj != null) {
            int len = lenObj.intValue();
            if (len == 0) {
                len = 256;
            }
            try {
                digest = MessageDigest.getInstance("SHA-" + len);
            } catch (NoSuchAlgorithmException e) {
                // ignore
            }
        }
    } else {
        throw new UDFArgumentTypeException(1,
                getFuncName() + " only takes constant as " + getArgOrder(1) + " argument");
    }

    ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    return outputOI;
}

From source file:de.nieblings.webapp.core.LicenceServiceImpl.java

/**
 * {@inheritDoc}/*  w  w w  .j  a va 2  s  .co m*/
 */
@Override
public boolean isLoginSlotFree() {
    if (counter.getUserCount() == 0) {
        return true;
    }

    Licence licence;
    try {
        licence = getLicence();
    } catch (BusinessServiceException e) {
        LOG.error("", e);
        return false;
    }

    final Integer users = licence.getUsers();
    if (users == null) {
        return true;
    }
    return users.intValue() > counter.getUserCount();
}

From source file:com.aurel.track.fieldType.runtime.matchers.converter.DoubleMatcherConverter.java

/**
 * Convert the object value to xml string for save
 * @param value/*  ww w. j av  a2 s  .  co  m*/
 * @param matcherRelation
 * @return
 */
@Override
public String toXMLString(Object value, Integer matcherRelation) {
    if (value == null || matcherRelation == null) {
        return null;
    }
    switch (matcherRelation.intValue()) {
    case MatchRelations.EQUAL:
    case MatchRelations.NOT_EQUAL:
    case MatchRelations.GREATHER_THAN:
    case MatchRelations.GREATHER_THAN_EQUAL:
    case MatchRelations.LESS_THAN:
    case MatchRelations.LESS_THAN_EQUAL:
        return value.toString();
    }
    return null;
}

From source file:com.tesora.dve.sql.statement.dml.AliasInformation.java

public boolean addAlias(String s) {
    Integer any = aliases.get(s);
    if (any == null)
        any = new Integer(1);
    else/*ww w.j a  v  a2s . com*/
        any = new Integer(any.intValue() + 1);
    return aliases.put(s, any) == null;
}

From source file:jp.co.opentone.bsol.linkbinder.view.correspon.AbstractCorresponPage.java

/**
 * Transfer?????.// w w  w  .ja  va 2s. co  m
 */
@PostConstruct
public void receiveTransferValue() {
    Flash flash = new Flash();
    this.backPage = flash.getValue(KEY_BACK_PAGE);
    this.corresponIds = flash.getValue(KEY_CORRESPON_IDS);

    Integer temp = flash.getValue(KEY_DISPLAY_INDEX);
    if (temp != null) {
        this.displayIndex = temp.intValue();
    }
}

From source file:com.aurel.track.fieldType.runtime.matchers.converter.SelectMatcherConverter.java

/**
 * Convert the object value to xml string for save
 * @param value/*from   ww  w  .  j  av a 2s .  co m*/
 * @param matcherRelation
 * @return
 */
@Override
public String toXMLString(Object value, Integer matcherRelation) {
    if (value == null || matcherRelation == null) {
        return null;
    }
    switch (matcherRelation.intValue()) {
    case MatchRelations.EQUAL:
    case MatchRelations.NOT_EQUAL:
        Integer[] intArr = null;
        try {
            intArr = (Integer[]) value;
        } catch (Exception e) {
            LOGGER.warn(
                    "Converting the " + value + " to Integer[] for XML string failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        if (intArr != null && intArr.length > 0) {
            Integer intValue = intArr[0];
            if (intValue != null) {
                return intValue.toString();
            }
        }
    }
    return "";
}