Example usage for java.lang Short valueOf

List of usage examples for java.lang Short valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Short valueOf(short s) 

Source Link

Document

Returns a Short instance representing the specified short value.

Usage

From source file:org.apache.directory.fortress.core.impl.PolicyDAO.java

/**
 *
 * @param le//from w  ww.  ja  va 2  s  .  c  o  m
 * @param sequence
 * @return
 * @throws LdapInvalidAttributeValueException 
 * @throws LdapException
 */
private PwPolicy unloadLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
    PwPolicy entity = new ObjectFactory().createPswdPolicy();
    entity.setSequenceId(sequence);
    entity.setName(getAttribute(le, SchemaConstants.CN_AT));
    String val = getAttribute(le, OLPW_MIN_AGE);

    if (StringUtils.isNotEmpty(val)) {
        entity.setMinAge(Integer.valueOf(val));
    }

    val = getAttribute(le, OLPW_MAX_AGE);

    if (StringUtils.isNotEmpty(val)) {
        entity.setMaxAge(Long.valueOf(val));
    }

    val = getAttribute(le, OLPW_IN_HISTORY);

    if (StringUtils.isNotEmpty(val)) {
        entity.setInHistory(Short.valueOf(val));
    }

    val = getAttribute(le, OLPW_CHECK_QUALITY);

    if (StringUtils.isNotEmpty(val)) {
        entity.setCheckQuality(Short.valueOf(val));
    }

    val = getAttribute(le, OLPW_MIN_LENGTH);

    if (StringUtils.isNotEmpty(val)) {
        entity.setMinLength(Short.valueOf(val));
    }

    val = getAttribute(le, OLPW_EXPIRE_WARNING);

    if (StringUtils.isNotEmpty(val)) {
        entity.setExpireWarning(Long.valueOf(val));
    }

    val = getAttribute(le, OLPW_GRACE_LOGIN_LIMIT);

    if (StringUtils.isNotEmpty(val)) {
        entity.setGraceLoginLimit(Short.valueOf(val));
    }

    val = getAttribute(le, OLPW_LOCKOUT);

    if (StringUtils.isNotEmpty(val)) {
        entity.setLockout(Boolean.valueOf(val));
    }

    val = getAttribute(le, OLPW_LOCKOUT_DURATION);

    if (StringUtils.isNotEmpty(val)) {
        entity.setLockoutDuration(Integer.valueOf(val));
    }

    val = getAttribute(le, OLPW_MAX_FAILURE);

    if (StringUtils.isNotEmpty(val)) {
        entity.setMaxFailure(Short.valueOf(val));
    }

    val = getAttribute(le, OLPW_FAILURE_COUNT_INTERVAL);

    if (StringUtils.isNotEmpty(val)) {
        entity.setFailureCountInterval(Short.valueOf(val));
    }

    val = getAttribute(le, OLPW_MUST_CHANGE);

    if (StringUtils.isNotEmpty(val)) {
        //noinspection BooleanConstructorCall
        entity.setMustChange(Boolean.valueOf(val));
    }

    val = getAttribute(le, OLPW_ALLOW_USER_CHANGE);

    if (StringUtils.isNotEmpty(val)) {
        entity.setAllowUserChange(Boolean.valueOf(val));
    }

    val = getAttribute(le, OLPW_SAFE_MODIFY);

    if (StringUtils.isNotEmpty(val)) {
        entity.setSafeModify(Boolean.valueOf(val));
    }

    return entity;
}

From source file:cn.wangsy.fast4j.util.IdcardUtils.java

/**
 * ???/*from ww w . j ava2 s.co  m*/
 * 
 * @param idCard ?
 * @return (yyyy)
 */
public static Short getYearByIdCard(String idCard) {
    Integer len = idCard.length();
    if (len < CHINA_ID_MIN_LENGTH) {
        return null;
    } else if (len == CHINA_ID_MIN_LENGTH) {
        idCard = conver15CardTo18(idCard);
    }
    return Short.valueOf(idCard.substring(6, 10));
}

From source file:org.ednovo.gooru.controllers.v2.api.QuizRestV2Controller.java

private Quiz buildQuizFromInputParameters(String data, User user) {
    Quiz quiz = JsonDeserializer.deserialize(data, Quiz.class);
    quiz.setGooruOid(UUID.randomUUID().toString());
    ContentType contentType = getQuizSerivce().getContentType(ContentType.RESOURCE);
    quiz.setContentType(contentType);//from   www.  j  a  va 2s.co m
    ResourceType resourceType = getQuizSerivce().getResourceType(ResourceType.Type.QUIZ.getType());
    quiz.setResourceType(resourceType);
    quiz.setLastModified(new Date(System.currentTimeMillis()));
    quiz.setCreatedOn(new Date(System.currentTimeMillis()));
    quiz.setCollectionType(CollectionType.Quiz.getCollectionType());
    if (!hasUnrestrictedContentAccess()) {
        quiz.setSharing(Sharing.PUBLIC.getSharing());
    } else {
        quiz.setSharing(
                quiz.getSharing() != null && (quiz.getSharing().equalsIgnoreCase(Sharing.PRIVATE.getSharing())
                        || quiz.getSharing().equalsIgnoreCase(Sharing.PUBLIC.getSharing())
                        || quiz.getSharing().equalsIgnoreCase(Sharing.ANYONEWITHLINK.getSharing()))
                                ? quiz.getSharing()
                                : Sharing.PUBLIC.getSharing());
    }
    quiz.setUser(user);
    quiz.setOrganization(user.getPrimaryOrganization());
    quiz.setCreator(user);
    quiz.setDistinguish(Short.valueOf("0"));
    quiz.setRecordSource(NOT_ADDED);
    quiz.setIsFeatured(0);
    quiz.setLastUpdatedUserUid(user.getGooruUId());
    return quiz;
}

From source file:ezbake.data.mongo.driver.thrift.ResultsWrapper.java

public Object getFieldValue(_Fields field) {
    switch (field) {
    case REQUEST_ID:
        return getRequestId();

    case RESULT_SET:
        return getResultSet();

    case RESPONSE_DATA:
        return getResponseData();

    case RESULT_SET_VALID:
        return Boolean.valueOf(isResultSetValid());

    case ROWS_EFFECTED:
        return Short.valueOf(getRowsEffected());

    case MONGOEXCEPTION:
        return getMongoexception();

    }// w ww.j  a v a2s  .  co m
    throw new IllegalStateException();
}

From source file:org.entrystore.repository.config.PropertiesConfiguration.java

/**
 * @see se.kth.cid.config.Config#getShort(java.lang.String)
 */// ww w.  j  a  v a 2s.c  o m
public short getShort(String key) {
    String strValue = config.getProperty(key);
    short shortValue = 0;

    if (strValue != null) {
        shortValue = Short.valueOf(strValue).shortValue();
    }

    return shortValue;
}

From source file:org.cropinformatics.ui.wizards.AbstractWizard.java

private boolean valueEquals(Object conditionProperty, Object object) {
    if (object != null && object instanceof String) {
        if (conditionProperty instanceof Boolean) {
            conditionProperty.equals(Boolean.valueOf((String) object));
        } else {/*ww w.  jav a 2 s .  c  o m*/
            if (conditionProperty instanceof Number) {
                try {
                    if (conditionProperty instanceof Integer) {
                        return conditionProperty.equals(Integer.valueOf((String) object));
                    } else {
                        if (conditionProperty instanceof Double) {
                            return conditionProperty.equals(Double.valueOf((String) object));
                        } else {
                            if (conditionProperty instanceof Short) {
                                return conditionProperty.equals(Short.valueOf((String) object));
                            } else {
                                if (conditionProperty instanceof Long) {
                                    return conditionProperty.equals(Long.valueOf((String) object));
                                } else {
                                    if (conditionProperty instanceof Float) {
                                        return conditionProperty.equals(Float.valueOf((String) object));
                                    }
                                }
                            }
                        }
                    }
                } catch (NumberFormatException e) {
                    return false;
                }
            } else {
                if (conditionProperty instanceof String) {
                    return conditionProperty.equals((String) object);
                }
            }
        }
    }

    return false;
}

From source file:org.mifos.accounts.loan.struts.actionforms.LoanAccountActionFormTest.java

/**
 * ignored cause failing when applicationConfiguration.custom.properties is changed.
 *///from w w  w  . j a  v a  2 s .  c o m
@Ignore
@Test
public void testValidateDefaultFees() {
    Short saveDigitsAfterDecimal = AccountingRules.getDigitsAfterDecimal();
    AccountingRules.setDigitsAfterDecimal(Short.valueOf("0"));
    form.setDefaultFees(createDefaultFees());
    ActionErrors errors = new ActionErrors();
    form.validateDefaultFee(errors, Locale.ENGLISH, TestUtils.RUPEE);
    Assert.assertEquals("No Error was expected", 0, errors.size());
    AccountingRules.setDigitsAfterDecimal(saveDigitsAfterDecimal);
}

From source file:cn.wangsy.fast4j.util.IdcardUtils.java

/**
 * ???//from   www .  ja v  a2 s  .  c om
 * 
 * @param idCard
 *            ?
 * @return (MM)
 */
public static Short getMonthByIdCard(String idCard) {
    Integer len = idCard.length();
    if (len < CHINA_ID_MIN_LENGTH) {
        return null;
    } else if (len == CHINA_ID_MIN_LENGTH) {
        idCard = conver15CardTo18(idCard);
    }
    return Short.valueOf(idCard.substring(10, 12));
}

From source file:com.zimbra.cs.mailbox.ACL.java

/** Returns the bitmask of rights granted to the user by the ACL, or
 *  <tt>null</tt> if there are no rights granted to anyone.  (Note that
 *  if rights are granted to <i>other</i> accounts but not to the
 *  specified user, returns <tt>0</tt>.)
 *
 * @param authuser   The user to gather rights for.
 * @return A <tt>Short</tt> containing the OR'ed-together rights
 *         granted to the user, or <tt>null</tt>. */
public Short getGrantedRights(Account authuser) throws ServiceException {
    if (mGrants.isEmpty()) {
        if (ZimbraLog.acl.isTraceEnabled()) {
            ZimbraLog.acl.trace("ACL.GrantedRights NULL (no grants)");
        }//from  w  w w  .j  ava  2  s  .c om
        return null;
    }

    short rightsGranted = 0;
    for (Grant grant : mGrants) {
        rightsGranted |= grant.getGrantedRights(authuser, this);
    }
    if ((rightsGranted & SUBFOLDER_RIGHTS) == SUBFOLDER_RIGHTS)
        rightsGranted |= RIGHT_SUBFOLDER;

    if (ZimbraLog.acl.isTraceEnabled()) {
        ZimbraLog.acl.trace("ACL.GrantedRights %s from %s grants", rightsGranted, mGrants.size());
    }
    return Short.valueOf(rightsGranted);
}

From source file:org.entrystore.repository.config.PropertiesConfiguration.java

/**
 * @see se.kth.cid.config.Config#getShort(java.lang.String, short)
 *//* w ww .  j  ava 2 s. c  o m*/
public short getShort(String key, short defaultValue) {
    String strValue = config.getProperty(key);
    short shortValue = 0;

    if (strValue != null) {
        shortValue = Short.valueOf(strValue).shortValue();
    } else {
        shortValue = defaultValue;
    }

    return shortValue;
}