Example usage for java.lang Short shortValue

List of usage examples for java.lang Short shortValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public short shortValue() 

Source Link

Document

Returns the value of this Short as a short .

Usage

From source file:org.jumpmind.db.platform.AbstractJdbcDdlReader.java

protected void readIndex(DatabaseMetaDataWrapper metaData, Map<String, Object> values,
        Map<String, IIndex> knownIndices) throws SQLException {
    Short indexType = (Short) values.get("TYPE");

    // we're ignoring statistic indices
    if ((indexType != null) && (indexType.shortValue() == DatabaseMetaData.tableIndexStatistic)) {
        return;//from  w  ww.j  av  a  2  s. c o  m
    }

    String indexName = (String) values.get("INDEX_NAME");

    if (indexName != null) {
        IIndex index = (IIndex) knownIndices.get(indexName);

        if (index == null) {
            if (((Boolean) values.get("NON_UNIQUE")).booleanValue()) {
                index = new NonUniqueIndex();
            } else {
                index = new UniqueIndex();
            }

            index.setName(indexName);
            knownIndices.put(indexName, index);
        }

        IndexColumn indexColumn = new IndexColumn();

        String columnName = (String) values.get("COLUMN_NAME");
        if (columnName.startsWith("\"") && columnName.endsWith("\"")) {
            columnName = columnName.substring(1, columnName.length() - 1);
        }
        indexColumn.setName(columnName);
        if (values.containsKey("ORDINAL_POSITION")) {
            indexColumn.setOrdinalPosition(((Short) values.get("ORDINAL_POSITION")).intValue());
        }
        index.addColumn(indexColumn);
    }
}

From source file:org.apache.flex.forks.velocity.runtime.configuration.Configuration.java

/**
 * Get a short associated with the given configuration key.
 *
 * @param key The configuration key.//from   w  w w .j av a2 s  .  c  om
 * @return The associated short.
 * @exception NoSuchElementException is thrown if the key doesn't
 * map to an existing object.
 * @exception ClassCastException is thrown if the key maps to an
 * object that is not a Short.
 * @exception NumberFormatException is thrown if the value mapped
 * by the key has not a valid number format.
 */
public short getShort(String key) {
    Short s = getShort(key, null);
    if (s != null) {
        return s.shortValue();
    } else {
        throw new NoSuchElementException('\'' + key + "' doesn't map to an existing object");
    }
}

From source file:org.mifos.accounts.persistence.AccountPersistence.java

public QueryResult search(String queryString, Short officeId) throws PersistenceException {

    AccountBO accountBO = findBySystemId(queryString);

    if (accountBO == null) {
        return null;
    }/*www. j  av a2s  .  c  o  m*/
    if (accountBO.getType() == AccountTypes.CUSTOMER_ACCOUNT) {
        return null;
    }
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.LOANACCOUNTIDSEARCH);
    ((QueryResultAccountIdSearch) queryResult).setSearchString(queryString);
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    String[] aliasNames = { "customerId", "centerName", "centerGlobalCustNum", "customerType",
            "branchGlobalNum", "branchName", "loanOfficerName", "loanOffcerGlobalNum", "customerStatus",
            "groupName", "groupGlobalCustNum", "clientName", "clientGlobalCustNum", "loanGlobalAccountNumber" };
    queryInputs.setPath("org.mifos.customers.business.CustomerSearch");
    queryInputs.setAliasNames(aliasNames);
    if (officeId != null) {
        if (officeId.shortValue() == 0) {
            namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID_COUNT;
            namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID;
        } else {
            namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_COUNT;
            namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH;
            paramList.add(typeNameValue("Short", "OFFICEID", officeId));
        }
        paramList.add(typeNameValue("String", "SEARCH_STRING", queryString));
    }
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setParamList(paramList);
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;

}

From source file:org.mifos.customers.persistence.CustomerPersistence.java

private QueryResult mainSearch(final String searchString, final Short officeId, final Short userId,
        final Short userOfficeId) throws PersistenceException, HibernateSearchException {
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = setQueryInputsValues(namedQuery, paramList);
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.CUSTOMERSEARCHRESULTS);
    if (officeId.shortValue() != 0) {
        namedQuery[0] = NamedQueryConstants.CUSTOMER_SEARCH_COUNT;
        namedQuery[1] = NamedQueryConstants.CUSTOMER_SEARCH;
        paramList.add(typeNameValue("Short", "OFFICEID", officeId));

    } else {/* w w w. ja  v a 2 s  .  co m*/
        namedQuery[0] = NamedQueryConstants.CUSTOMER_SEARCH_COUNT_NOOFFICEID;
        namedQuery[1] = NamedQueryConstants.CUSTOMER_SEARCH_NOOFFICEID;
        paramList.add(typeNameValue("String", "OFFICE_SEARCH_ID",
                new OfficePersistence().getOffice(userOfficeId).getSearchId() + "%"));
    }
    paramList.add(typeNameValue("String", "SEARCH_STRING", "%" + searchString + "%"));
    if (searchString.contains(" ")) {
        List<String> words = new ArrayList<String>(Arrays.asList(searchString.split(" +")));
        // we support up to 3 words for client search, so join more words with spaces or fill with empty
        // strings to get exactly 3 words
        if (words.size() > 3) {
            for (int i = 3; i < words.size(); ++i) {
                words.set(2, words.get(2) + " " + words.get(i));
            }
            words = words.subList(0, 3);
        } else if (words.size() < 3) {
            int elementsToAdd = 3 - words.size();
            for (int i = 0; i < elementsToAdd; ++i) {
                words.add("");
            }
        }
        paramList.add(typeNameValue("String", "SEARCH_STRING1", words.get(0)));
        paramList.add(typeNameValue("String", "SEARCH_STRING2", words.get(1)));
        paramList.add(typeNameValue("String", "SEARCH_STRING3", words.get(2)));
    } else {
        paramList.add(typeNameValue("String", "SEARCH_STRING1", searchString));
        paramList.add(typeNameValue("String", "SEARCH_STRING2", ""));
        paramList.add(typeNameValue("String", "SEARCH_STRING3", ""));
    }
    setParams(paramList, userId);
    queryResult.setQueryInputs(queryInputs);
    return queryResult;

}

From source file:org.mifos.accounts.persistence.LegacyAccountDao.java

public QueryResult search(String queryString, Short officeId) throws PersistenceException {

    AccountBO accountBO = findBySystemId(queryString);

    if (accountBO == null) {
        return null;
    }/*from  w  ww  .j  av a2  s.  co  m*/
    if (accountBO.getType() == AccountTypes.CUSTOMER_ACCOUNT
            || accountBO.getType() == AccountTypes.INDIVIDUAL_LOAN_ACCOUNT) {
        return null;
    }
    QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.LOANACCOUNTIDSEARCH);
    ((QueryResultAccountIdSearch) queryResult).setSearchString(queryString);
    String[] namedQuery = new String[2];
    List<Param> paramList = new ArrayList<Param>();
    QueryInputs queryInputs = new QueryInputs();
    String[] aliasNames = { "customerId", "centerName", "centerGlobalCustNum", "customerType",
            "branchGlobalNum", "branchName", "loanOfficerName", "loanOffcerGlobalNum", "customerStatus",
            "groupName", "groupGlobalCustNum", "clientName", "clientGlobalCustNum", "loanGlobalAccountNumber" };
    queryInputs.setPath("org.mifos.customers.business.CustomerSearchDto");
    queryInputs.setAliasNames(aliasNames);
    if (officeId != null) {
        if (officeId.shortValue() == 0) {
            namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID_COUNT;
            namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH_NOOFFICEID;
        } else {
            namedQuery[0] = NamedQueryConstants.ACCOUNT_ID_SEARCH_COUNT;
            namedQuery[1] = NamedQueryConstants.ACCOUNT_ID_SEARCH;
            paramList.add(typeNameValue("Short", "OFFICEID", officeId));
        }
        paramList.add(typeNameValue("String", "SEARCH_STRING", queryString));
    }
    queryInputs.setQueryStrings(namedQuery);
    queryInputs.setParamList(paramList);
    try {
        queryResult.setQueryInputs(queryInputs);
    } catch (HibernateSearchException e) {
        throw new PersistenceException(e);
    }
    return queryResult;

}

From source file:net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl.java

@Override
public IDevice findClassDevice(IEntityClass entityClass, long macAddress, Short vlan, Integer ipv4Address)
        throws IllegalArgumentException {
    if (vlan != null && vlan.shortValue() <= 0)
        vlan = null;//from   ww w  .  ja v  a2 s .  co  m
    if (ipv4Address != null && ipv4Address == 0)
        ipv4Address = null;
    Entity e = new Entity(macAddress, vlan, ipv4Address, null, null, null);
    if (entityClass == null || !allKeyFieldsPresent(e, entityClass.getKeyFields())) {
        throw new IllegalArgumentException("Not all key fields and/or "
                + " no source device specified. Required fields: " + entityClassifier.getKeyFields());
    }
    return findDestByEntity(entityClass, e);
}

From source file:net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl.java

@Override
public IDevice findDevice(long macAddress, Short vlan, Integer ipv4Address, Long switchDPID, Integer switchPort)
        throws IllegalArgumentException {
    if (vlan != null && vlan.shortValue() <= 0)
        vlan = null;/*from  w  ww .j  ava 2 s .com*/
    if (ipv4Address != null && ipv4Address == 0)
        ipv4Address = null;
    Entity e = new Entity(macAddress, vlan, ipv4Address, switchDPID, switchPort, null);
    if (!allKeyFieldsPresent(e, entityClassifier.getKeyFields())) {
        throw new IllegalArgumentException(
                "Not all key fields specified." + " Required fields: " + entityClassifier.getKeyFields());
    }
    return findDeviceByEntity(e);
}

From source file:org.mifos.customers.persistence.CustomerDaoHibernate.java

private boolean isPermissionAllowed(Short newState, UserContext userContext, Short flagSelected,
        Short recordOfficeId, Short recordLoanOfficerId) {
    return ActivityMapper.getInstance().isStateChangePermittedForCustomer(newState.shortValue(),
            null != flagSelected ? flagSelected.shortValue() : 0, userContext, recordOfficeId,
            recordLoanOfficerId);//from w  w  w . ja va  2  s.c  o  m
}

From source file:org.mifos.customers.persistence.CustomerDaoHibernate.java

private void updateAccountsForOneCustomer(final Integer customerId, final Short parentLO,
        final Connection connection) {

    try {//from  www. j  a  va2 s  . c  om
        Statement statement = connection.createStatement();
        String sql = "update account " + " set personnel_id = " + parentLO.shortValue()
                + " where account.customer_id = " + customerId.intValue();
        statement.executeUpdate(sql);
        statement.close();
    } catch (SQLException e) {
        throw new MifosRuntimeException(e);
    }
}

From source file:pltag.parser.semantics.DepTreeState.java

/**
 * /*from w  w w  .ja  va2s . c  om*/
//     * @param coveredNodes map of verification node ids to (verified) shadow tree node ids
 * @param elemTreeState
 * @param coveredNodes map of (verified) shadow tree node ids to verification node ids
 * @param tree
 * @param ipIdOffset
 * @param offsetNodeIdsOfShadowTree 
 * @param shadowTreeRoot 
 * @param words 
 * @param origPosTags
 * @param operation the parsing operation applied (adjunction, substitution, verification or initial)     
 * @param timestamp 
 */
public void updateDependencies(TreeState elemTreeState, DualHashBidiMap<Integer, Integer> coveredNodes,
        ElementaryStringTree tree, short ipIdOffset, DualHashBidiMap<Short, Short> offsetNodeIdsOfShadowTree,
        Node shadowTreeRoot, String[] words, String[] origPosTags, String operation, int timestamp) {
    retainInfoFromTreeHeuristics(elemTreeState, shadowTreeRoot, tree, ipIdOffset, false, timestamp, true,
            coveredNodes, offsetNodeIdsOfShadowTree);
    DepNode anchorNode = getAnchorNode(tree, ipIdOffset, timestamp);
    Set<Integer> processedNodes = new HashSet<>();
    // First check if the verifying tree has roles
    if (tree.hasRoles()) {
        MultiValueMap<Integer, Role> rolesPerNode = getRolesPerNode(tree, ipIdOffset);
        // Browse through all candidate integration points
        for (Integer ipCandidate : rolesPerNode.keySet()) {
            processedNodes.add(ipCandidate);
            // find the ones that are part of the verification tree, hence exist on the prefix tree as part of shadow trees
            Integer shadowNodeId = coveredNodes.getKey(ipCandidate - ipIdOffset);
            if (shadowNodeId != null) {
                // find the arc with the partially complete dependency
                Short offsetShadowId = offsetNodeIdsOfShadowTree.get(shadowNodeId.shortValue());
                if (offsetShadowId != null) {
                    Collection<DependencyArc> arcs = dependencies
                            .getDependenciesByIntegPoint(new DepNode(offsetShadowId.shortValue(), timestamp));
                    if (arcs != null) {
                        //                            for(DependencyArc arc : arcs)
                        Iterator<DependencyArc> iterator = arcs.iterator();
                        while (iterator.hasNext()) {
                            DependencyArc arc = iterator.next();
                            if (arc.isIncomplete()) {
                                if (tree.isRelation() && arc.isRelationIncomplete()) // avoid filling in an already complete relation entry
                                {
                                    filterRoles(arc, rolesPerNode.getCollection(ipCandidate));
                                    setRelation(arc, anchorNode, iterator, words, origPosTags, operation, true,
                                            false);
                                    // possibly created a complete arc, so we can identify and disambiguate role labels discriminatively
                                    boolean keepArc = identifyArcAndDisambiguateRoles(model, arc, words,
                                            origPosTags);
                                    if (!keepArc)
                                        removeArcSafe(arc, arc.getIntegrationPoint(), iterator);
                                }
                                //                        else if(!tree.isRelation() && arc.isArgumentIncomplete())
                                // removed restriction of above if statement: a relation can be an argument to another relation
                                else if (arc.isArgumentIncomplete()) {
                                    filterRoles(arc, rolesPerNode.getCollection(ipCandidate));
                                    if (applyConllHeuristics) // Apply infinitive marker heuristic, if necessary
                                        applyInfinitiveMarkerHeuristic(arc, anchorNode, iterator, words,
                                                origPosTags, operation, true, false);
                                    else {
                                        // Apply PP heuristic, if neceessary
                                        boolean keepArc = applyPPArgumentHeuristic(arc, tree, anchorNode,
                                                ipIdOffset, words, origPosTags, operation, true, false);
                                        // Apply infinitive marker heuristic, if necessary
                                        if (keepArc)
                                            applyInfinitiveMarkerHeuristic(arc, anchorNode, iterator, words,
                                                    origPosTags, operation, true, false);
                                    }
                                    //                            setArgument(arc, anchorNode);
                                }
                            } // if
                        } //for
                    } // if
                } // if                    
                else // the shadow sub-tree of the prefix tree doesn't have a role. Proceed with the normal addition of a new dependency
                {
                    addDependency(new DepNode(ipCandidate, timestamp), tree,
                            (short) (ipCandidate.shortValue() - ipIdOffset), ipIdOffset, rolesPerNode,
                            shadowTreeRoot, false, words, origPosTags, operation, true, timestamp);
                    //                        System.out.println("Check! If we never end up here, consider dropping the if statement above");
                }
            } // if
              // integration points on the elementary tree that are not verifying a shadow sub-tree on the prefix tree.
              // we need to consider it as an incomplete dependency
            else {
                addIncompleteDependency(ipCandidate, tree, ipIdOffset, false, tree.isRelation(),
                        rolesPerNode.getCollection(ipCandidate), null, words, origPosTags, operation, true,
                        timestamp);
            }
        } // for all candidate ips
    } // if hasRoles
      // Process the rest of the covered nodes in the shadow subtree of the prefix tree that have a role, hence a dependency arc already observed
    for (Entry<Integer, Integer> e : coveredNodes.entrySet()) {
        DependencyArc arc;
        Short offsetShadowId = offsetNodeIdsOfShadowTree.get(e.getValue().shortValue());
        if (offsetShadowId != null && !processedNodes.contains(e.getValue() + ipIdOffset)) {
            Collection<DependencyArc> arcsByIp = dependencies
                    .getDependenciesByIntegPoint(new DepNode(offsetShadowId.shortValue(), timestamp));
            //                if((arc = dependencies.pollArcWithShadowArg(new DepNode(offsetShadowId.shortValue(), timestamp))) != null)
            //                if((arc = dependencies.getArcWithShadowArg(new DepNode(offsetShadowId.shortValue(), timestamp))) != null)
            //                {
            //                    updateDependenciesUnderCoveredNode(tree, coveredNodes, offsetNodeIdsOfShadowTree, timestamp, anchorNode, arc, null, origPosTags);
            //                }
            //                else if(arcsByIp  != null)
            if (arcsByIp != null) {
                //                    for(DependencyArc arcByIp : arcsByIp)
                Iterator<DependencyArc> iterator = arcsByIp.iterator();
                while (iterator.hasNext()) {
                    DependencyArc arcByIp = iterator.next();
                    updateDependenciesUnderCoveredNode(tree, coveredNodes, offsetNodeIdsOfShadowTree, timestamp,
                            anchorNode, arcByIp, iterator, words, origPosTags);
                }
            }
        }
    }
    if (tree.isRelation()) {
        addHangingRelation(tree, ipIdOffset, words, origPosTags, operation, true, false, timestamp);
    }
    dependencies.postProcessArcs(operation, true, false);
}