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.ottogroup.bi.streaming.operator.json.aggregate.functions.BooleanContentAggregateFunction.java

/**
 * @see com.ottogroup.bi.streaming.operator.json.aggregate.functions.JsonContentAggregateFunction#count(java.lang.Integer)
 *///from w w w  . j av a2  s  . c  o  m
public Integer count(Integer value) throws Exception {
    if (value == null)
        return Integer.valueOf(1);
    return Integer.valueOf(value.intValue() + 1);
}

From source file:ch.javaee.basicMvc.service.MyUserDetailsService.java

/**
 * Converts a numerical role to an equivalent list of roles
 *
 * @param role the numerical role/*w w w.ja v  a 2  s  . c  o m*/
 * @return list of roles as as a list of {@link String}
 */
public List<String> getRoles(Integer role) {
    List<String> roles = new ArrayList<String>();
    if (role.intValue() == 1) {
        roles.add("ROLE_USER");
        roles.add("ROLE_ADMIN");
    } else if (role.intValue() == 2) {
        roles.add("ROLE_USER");
    }
    return roles;
}

From source file:im.delight.java.emoji.Emoji.java

/**
 * Converts between emoticons and their corresponding Unicode Emoji in the given text
 *
 * @param text the String to search and replace in
 * @param reverse whether to replace emoticons with emoji as usual (false) or revert emoji to emoticons (true)
 * @return the new String containing the the converted entities
 *///  w  ww .  j  a  va 2s. co m
public static String replaceInText(String text, boolean reverse) {
    final ReplacementsMap replacements = ReplacementsMap.getInstance();
    String emoticon;
    Integer codepoint;

    for (Map.Entry<String, Integer> entry : replacements.entrySet()) {
        if (entry != null) {
            emoticon = entry.getKey();
            codepoint = entry.getValue();
            if (emoticon != null && codepoint != null) {
                String unicodeChar = getUnicodeChar(codepoint.intValue());
                if (reverse) {
                    text = text.replace(unicodeChar, emoticon);
                } else {
                    text = text.replaceAll(getEmoticonSearchRegex(emoticon), unicodeChar);
                }
            }
        }
    }

    // 
    //text = filter(text);

    return text;
}

From source file:org.messic.server.facade.security.CustomUserDetailsService.java

/**
 * Converts a numerical role to an equivalent list of roles
 * /*from  w ww  .ja  v a2s .  c o  m*/
 * @param role the numerical role
 * @return list of roles as as a list of {@link String}
 */
public List<String> getRoles(Integer role) {
    List<String> roles = new ArrayList<String>();

    if (role.intValue() == 1) {
        roles.add("ROLE_USER");
        roles.add("ROLE_ADMIN");

    } else if (role.intValue() == 2) {
        roles.add("ROLE_USER");
    }

    return roles;
}

From source file:bhl.pages.handler.PagesCropRectHandler.java

/**
 * Get the plain text of a page. Assume parameters version1, pageid 
 * (image file name minus extension) and docid. Assume also that there 
 * is a corcode at docid/pages. (Should already have checked for this)
 * @param request the original http request
 * @param response the response/*  ww  w. j  a  v a 2 s  .c  o  m*/
 * @param urn the urn used for the request
 * @throws MissingDocumentException 
 */
public void handle(HttpServletRequest request, HttpServletResponse response, String urn)
        throws MissingDocumentException {
    try {
        Connection conn = Connector.getConnection();
        String pageid = request.getParameter(Params.PAGEID);
        Integer num = new Integer(pageid);
        String content = conn.getFromDbByIntField(Database.PAGES, num.intValue(), JSONKeys.BHL_PAGE_ID);
        JSONObject jobj = (JSONObject) JSONValue.parse(content);
        JSONArray cropRect = (JSONArray) jobj.get(JSONKeys.CROP_RECT);
        if (cropRect == null)
            cropRect = getDefaultCropRect();
        response.setContentType("text/plain;charset=UTF-8");
        response.getWriter().println(cropRect.toJSONString());
    } catch (Exception e) {
        throw new MissingDocumentException(e);
    }
}

From source file:tachyon.master.EditLogOperationTest.java

@Test
public void createDependencyTest() throws IOException {
    EditLogOperation editLogOperation = OBJECT_MAPPER.readValue(CREATE_DEPENDENCY_TYPE.getBytes(),
            EditLogOperation.class);

    // get all parameters for "CREATE_DEPENDENCY"
    List<Integer> parents = editLogOperation.get("parents", new TypeReference<List<Integer>>() {
    });//  w  w w. j a  va  2  s  . c o  m
    Assert.assertEquals(3, parents.size());

    List<Integer> children = editLogOperation.get("children", new TypeReference<List<Integer>>() {
    });
    Assert.assertEquals(4, children.size());

    String commandPrefix = editLogOperation.getString("commandPrefix");
    Assert.assertEquals("fake command", commandPrefix);

    List<ByteBuffer> data = editLogOperation.getByteBufferList("data");
    Assert.assertEquals(1, data.size());
    String decodedBase64 = new String(data.get(0).array(), "UTF-8");
    Assert.assertEquals(new String(Base64.decodeBase64("AAAAAAAAAAAAAA==")), decodedBase64);

    String comment = editLogOperation.getString("comment");
    Assert.assertEquals("Comment Test", comment);

    String framework = editLogOperation.getString("framework");
    Assert.assertEquals("Tachyon Examples", framework);

    String frameworkVersion = editLogOperation.getString("frameworkVersion");
    Assert.assertEquals("0.3", frameworkVersion);

    DependencyType dependencyType = editLogOperation.get("dependencyType", DependencyType.class);
    Assert.assertEquals(DependencyType.Narrow, dependencyType);

    Integer depId = editLogOperation.getInt("dependencyId");
    Assert.assertEquals(1, depId.intValue());

    Long creationTimeMs = editLogOperation.getLong("creationTimeMs");
    Assert.assertEquals(1409349750338L, creationTimeMs.longValue());
}

From source file:org.socialsignin.spring.data.dynamodb.repository.query.PartTreeDynamoDBQuery.java

@Override
protected boolean isSingleEntityResultsRestriction() {
    Integer resultsRestiction = getResultsRestrictionIfApplicable();
    return resultsRestiction != null && resultsRestiction.intValue() == 1;
}

From source file:org.horizontaldb.shard.hibernate.advise.TenantContextEnricherAspect.java

private void decreaseFrameCount() {
    Integer count = frameCounter.get();

    if (count != null) {
        frameCounter.set(count.intValue() - 1);
    }/*from   w  w  w .jav a2  s  . co  m*/
}

From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.AssigneeRequirementStatistics.java

/**
 * {@inheritdoc}//w  w w .  j  a v  a  2 s  .  c om
 */
@Override
public void update() {
    final List<Requirement> requirements = RequirementDatabase.getInstance().getFilteredRequirements(); // refresh list of
    // requirements
    // TODO: replace with a method to get all users, record them as
    // zero-counts in the map, and then simply work through and increment
    // for each requirement
    Map<String, Integer> mapData = new HashMap<String, Integer>();
    for (final Requirement requirement : requirements) {
        // for each set of assigned users
        for (final String user : requirement.getUsers()) {
            // if a user has not been encountered before, add him/her to the
            // map
            if (mapData.get(user) == null) {
                mapData.put(user, new Integer(1)); // note that this
                // requirement is one to
                // which the user is
                // assigned!
            }
            // otherwise, simply increment the value
            else {
                final Integer oldValue = mapData.get(user);
                mapData.put(user, new Integer(oldValue.intValue() + 1));
            }
        }
    }

    //parse into a list
    for (String key : mapData.keySet()) {
        data.add(new StringIntegerPair(key, mapData.get(key)));
    }

}

From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatusRequirementStatistics.java

@Override
public void update() {
    final List<Requirement> requirements = RequirementDatabase.getInstance().getFilteredRequirements(); // refresh list of
    // requirements
    Map<String, Integer> mapData = new HashMap<String, Integer>();

    // for every possible status
    for (final Status status : Status.values()) {
        mapData.put(status.toString(), 0); // insert the status in the
        // data set with zero
        // counted requirements
    }//from  w w  w .  j  a  va2 s .co  m
    // for every requirement in this project
    for (final Requirement requirement : requirements) {
        final Status status = requirement.getStatus();
        final Integer oldValue = mapData.get(status.toString());
        mapData.put(status.toString(), new Integer(oldValue.intValue() + 1));
        // increment the number of requirements for a given status
    }

    mapData.remove("BLANK");

    //parse into a list
    for (String key : mapData.keySet()) {
        data.add(new StringIntegerPair(key, mapData.get(key)));
    }
}