Java 类org.apache.commons.collections.map.ListOrderedMap 实例源码

项目:gemfirexd-oss    文件:CreationParameters.java   
/**
 * Returns the parameters for the given table.
 * 
 * @param table The table
 * @return The parameters
 */
public Map getParametersFor(Table table)
{
    ListOrderedMap result       = new ListOrderedMap();
    Map            globalParams = (Map)_parametersPerTable.get(null);
    Map            tableParams  = (Map)_parametersPerTable.get(table.getQualifiedName());

    if (globalParams != null)
    {
        result.putAll(globalParams);
    }
    if (tableParams != null)
    {
        result.putAll(tableParams);
    }
    return result;
}
项目:spring-boot    文件:MyBeanUtils.java   
/**
 * 根据给定的条件,把 list 中的 javabean 排序。
 * 用到了 commons beanutils 和  commons.collections
 *
 * @param list           待排序的 list
 * @param listOrderedMap 排序条件。
 *                       这是一个有序的 list ,排序条件按照加入到 list 的 bean 的属性(map 的 key)的先后顺序排序。
 *                       listOrderedMap 的 key 为待排序的 bean 的属性名称,值为是否按该属性的正序排序,true 为正序,false 为逆序。
 *                       使用方法见本类的 testSortListBeans() 方法例子,使用时注意不要写错 bean 的属性名称。
 * @param <T>            list 中的 bean 类型
 */
public static <T> void sortListBeans(List<T> list, ListOrderedMap listOrderedMap) {

    int num = listOrderedMap.size();
    ArrayList sortFields = new ArrayList();

    for (int i = 0; i < num; i++) {
        //  System.out.println("key =" + listOrderedMap.get(i) + " , value=" + listOrderedMap.getValue(i));
        Comparator comp = ComparableComparator.getInstance();

        comp = ComparatorUtils.nullLowComparator(comp);  //允许null

        if ((Boolean) listOrderedMap.getValue(i) == false)
            comp = ComparatorUtils.reversedComparator(comp); //逆序

        Comparator cmp = new BeanComparator((String) listOrderedMap.get(i), comp);
        sortFields.add(cmp);
    }

    ComparatorChain multiSort = new ComparatorChain(sortFields);
    Collections.sort(list, multiSort);
}
项目:gemfirexd-oss    文件:CreationParameters.java   
/**
 * Returns the parameters for the given table.
 * 
 * @param table The table
 * @return The parameters
 */
public Map getParametersFor(Table table)
{
    ListOrderedMap result       = new ListOrderedMap();
    Map            globalParams = (Map)_parametersPerTable.get(null);
    Map            tableParams  = (Map)_parametersPerTable.get(table.getQualifiedName());

    if (globalParams != null)
    {
        result.putAll(globalParams);
    }
    if (tableParams != null)
    {
        result.putAll(tableParams);
    }
    return result;
}
项目:Express4J    文件:RouterScanner.java   
private static Map<String,Class<?>> parseMethodParams(String str) {
    OrderedMap params = new ListOrderedMap();
    if (str.contains("(") && str.contains(")")) {
        String target = str.substring(str.indexOf("(") + 1, str.lastIndexOf(")"));
        String[] nameAndTypes = target.split(",");
        for (String nameAndType : nameAndTypes) {
            String[] paramWrapper = nameAndType.split(":");
            String name = paramWrapper[0];
            String type = paramWrapper[1];
            try {
                params.put(name,Class.forName(type));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
    return params;
}
项目:Jouve-Project    文件:SpellChecker.java   
@SuppressWarnings("unchecked")
public static void main(String[] args) {
    System.out.println(System.getProperty("os.arch"));
    SpellChecker spellChecker = new SpellChecker("./dictionaries");
    ListOrderedMap suggestion = spellChecker
            .suggest("jestion de proget", "web");
    List<String> keys = suggestion.keyList();
    for (String key : keys) {
        if (suggestion.get(key) != null) {
            System.out.print(key + " : ");
            List<String> keySugs = (List<String>) suggestion.get(key);
            for (String sug : keySugs) {
                System.out.print(sug + ", ");
            }
            System.out.println();
        } else {
            System.out.println(key);
        }
    }
}
项目:Jouve-Project    文件:SpellCheckerPanel.java   
@SuppressWarnings("unchecked")
private String getSuggestedSearchAsString() {
    StringBuffer sb = new StringBuffer();
    ListOrderedMap suggestedSearch = (ListOrderedMap) getModelObject();
    for (String motOriginal : (Set<String>) suggestedSearch.keySet()) {
        List<String> suggestedWords = (List<String>) suggestedSearch.get(motOriginal);
        if (suggestedWords == null || suggestedWords.isEmpty()) {
            sb.append(motOriginal);
        } else {
            // First word
            sb.append(suggestedWords.get(0));
        }
        sb.append(" ");
    }
    if (sb.length() > 0) {
        // Supprimer le dernier espace
        sb.replace(sb.length() - 1, sb.length(), "");
    }
    return sb.toString();
}
项目:Jouve-Project    文件:SpellCheckerPanel.java   
@SuppressWarnings("unchecked")
   public boolean hasManySuggestions() {
    boolean manySuggestions = false;
    boolean firstSuggestion = true;
       ListOrderedMap suggestedSearch = (ListOrderedMap) getModelObject();
       for (String motOriginal : (Set<String>) suggestedSearch.keySet()) {
           List<String> suggestedWords = (List<String>) suggestedSearch.get(motOriginal);
           if (suggestedWords != null && suggestedWords.size() > 1) {
               if (firstSuggestion) {
                   firstSuggestion = false;
               } else {
                   manySuggestions = true;
                   break;
               }
           }
       }    
       return manySuggestions;
}
项目:egovframework.rte.root    文件:MapTypeParameterTest.java   
@Test
public void testEgovMapTest() throws Exception {
    Map<String, Object> map = makeMap();

    // insert
    mapTypeMapper.insertDept("insertDeptUsingMap", map);

    // select
    Map<String, Object> resultMap =
        mapTypeMapper.selectDept("selectDeptUsingEgovMap", map);

    // check
    assertNotNull(resultMap);
    // resultType을 EgovMap으로 명시하면
    // key 를 camel case 로 변환하여 전달해줌
    // EgovMap 은 ListOrderedMap 을 extends 하고 있음
    assertTrue(resultMap instanceof ListOrderedMap);
    assertEquals(map.get("deptNo"), resultMap.get("deptNo"));
    assertEquals(map.get("deptName"), resultMap.get("deptName"));
    assertEquals(map.get("loc"), resultMap.get("loc"));
}
项目:egovframework.rte.root    文件:MapTypeParameterTest.java   
@Test
public void testEgovMapTest() throws Exception {
    Map<String, Object> map = makeMap();

    // insert
    mapTypeDAO.insertDept("insertDeptUsingMap", map);

    // select
    Map<String, Object> resultMap =
        mapTypeDAO.selectDept("selectDeptUsingEgovMap", map);

    // check
    assertNotNull(resultMap);
    // EgovMap 으로 resultClass 를 명시하면
    // key 를 camel case 로 변환하여 전달해줌
    // EgovMap 은 ListOrderedMap 을 extends 하고 있음
    assertTrue(resultMap instanceof ListOrderedMap);
    assertEquals(map.get("deptNo"), resultMap.get("deptNo"));
    assertEquals(map.get("deptName"), resultMap.get("deptName"));
    assertEquals(map.get("loc"), resultMap.get("loc"));
}
项目:apache-ddlutils    文件:CreationParameters.java   
/**
 * Returns the parameters for the given table.
 * 
 * @param table The table
 * @return The parameters
 */
public Map getParametersFor(Table table)
{
    ListOrderedMap result       = new ListOrderedMap();
    Map            globalParams = (Map)_parametersPerTable.get(null);
    Map            tableParams  = (Map)_parametersPerTable.get(table);

    if (globalParams != null)
    {
        result.putAll(globalParams);
    }
    if (tableParams != null)
    {
        result.putAll(tableParams);
    }
    return result;
}
项目:apache-ddlutils    文件:JdbcModelReader.java   
/**
 * Retrieves the foreign keys of the indicated table.
 *
 * @param metaData  The database meta data
 * @param tableName The name of the table from which to retrieve FK information
 * @return The foreign keys
 */
protected Collection readForeignKeys(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    Map       fks    = new ListOrderedMap();
    ResultSet fkData = null;

    try
    {
        fkData = metaData.getForeignKeys(tableName);

        while (fkData.next())
        {
            Map values = readColumns(fkData, getColumnsForFK());

            readForeignKey(metaData, values, fks);
        }
    }
    finally
    {
        if (fkData != null)
        {
            fkData.close();
        }
    }
    return fks.values();
}
项目:apache-ddlutils    文件:JdbcModelReader.java   
/**
 * Determines the indices for the indicated table.
 * 
 * @param metaData  The database meta data
 * @param tableName The name of the table
 * @return The list of indices
 */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    Map       indices   = new ListOrderedMap();
    ResultSet indexData = null;

    try 
    {
        indexData = metaData.getIndices(tableName, false, false);

        while (indexData.next())
        {
            Map values = readColumns(indexData, getColumnsForIndex());

            readIndex(metaData, values, indices);
        }
    }
    finally
    {
        if (indexData != null)
        {
            indexData.close();
        }
    }
    return indices.values();
}
项目:scipio-erp    文件:TransactionUtil.java   
/**
* Remove the stamp from stack (when resuming)
*/
private static void popTransactionStartStamp() {
    ListOrderedMap map = (ListOrderedMap) suspendedTxStartStamps.get();
    if (map.size() > 0) {
        transactionStartStamp.set((Timestamp) map.remove(map.lastKey()));
    } else {
        Debug.logError("Error in transaction handling - no saved start stamp found - using NOW.", module);
        transactionStartStamp.set(UtilDateTime.nowTimestamp());
    }
}
项目:gemfirexd-oss    文件:FirebirdModelReader.java   
/**
 * {@inheritDoc}
 */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    // Jaybird is not able to read indices when delimited identifiers are turned on,
    // so we gather the data manually using Firebird's system tables
    final String query =
        "SELECT a.RDB$INDEX_NAME INDEX_NAME, b.RDB$RELATION_NAME TABLE_NAME, b.RDB$UNIQUE_FLAG NON_UNIQUE, " +
        "a.RDB$FIELD_POSITION ORDINAL_POSITION, a.RDB$FIELD_NAME COLUMN_NAME, 3 INDEX_TYPE " +
        "FROM RDB$INDEX_SEGMENTS a, RDB$INDICES b WHERE a.RDB$INDEX_NAME=b.RDB$INDEX_NAME AND b.RDB$RELATION_NAME = ?";

    Map               indices = new ListOrderedMap();
    PreparedStatement stmt    = null;

    try
    {
        stmt = getConnection().prepareStatement(query);

        stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());

        ResultSet indexData = stmt.executeQuery();

        while (indexData.next())
        {
            Map values = readColumns(indexData, getColumnsForIndex());

            // we have to reverse the meaning of the unique flag; also, null means false
            values.put("NON_UNIQUE", (values.get("NON_UNIQUE") == null) || Boolean.FALSE.equals(values.get("NON_UNIQUE")) ? Boolean.TRUE : Boolean.FALSE);
            // and trim the names
            values.put("INDEX_NAME",  ((String)values.get("INDEX_NAME")).trim());
            values.put("TABLE_NAME",  ((String)values.get("TABLE_NAME")).trim());
            values.put("COLUMN_NAME", ((String)values.get("COLUMN_NAME")).trim());
            readIndex(metaData, values, indices);
        }
    }
    finally
    {
        closeStatement(stmt);
    }
    return indices.values();
}
项目:gemfirexd-oss    文件:JdbcModelReader.java   
/**
 * Retrieves the foreign keys of the indicated table.
 *
 * @param metaData  The database meta data
 * @param tableName The name of the table from which to retrieve FK information
 * @return The foreign keys
 */
protected Collection readForeignKeys(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    Map       fks    = new ListOrderedMap();
    ResultSet fkData = null;

    try
    {
        // GemStone changes BEGIN
        //fkData = metaData.getForeignKeys(metaData.escapeForSearch(tableName));

        //The underlying DatabaseMetaData.getImportedKeys does not take the string pattern,
        //so do not need escape the _, see ticket 44911
        fkData = metaData.getForeignKeys(tableName);
        // GemStone changes BEGIN

        while (fkData.next())
        {
            Map values = readColumns(fkData, getColumnsForFK());

            readForeignKey(metaData, values, fks);
        }
    }
    finally
    {
        closeResultSet(fkData);
    }
    return fks.values();
}
项目:gemfirexd-oss    文件:JdbcModelReader.java   
/**
 * Determines the indices for the indicated table.
 * 
 * @param metaData  The database meta data
 * @param tableName The name of the table
 * @return The list of indices
 */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    Map       indices   = new ListOrderedMap();
    ResultSet indexData = null;

    try 
    {
        // GemStone changes BEGIN
        //indexData = metaData.getIndices(metaData.escapeForSearch(tableName), false, false);

        //The underlying DatabaseMetaData.getIndexInfo does not take the string pattern,
        //so do not need escape the _, see ticket 44911
        indexData = metaData.getIndices(tableName, false, false);
        // GemStone changes BEGIN
        while (indexData.next())
        {
            Map values = readColumns(indexData, getColumnsForIndex());

            readIndex(metaData, values, indices);
        }
    }
    finally
    {
        closeResultSet(indexData);
    }
    return indices.values();
}
项目:spring-boot    文件:MyBeanUtils.java   
private void testSortListBeans() {

        ListOrderedMap properties = new ListOrderedMap();
        // properties.put("name", true);
        properties.put("name", false);
        //properties.put("passwd", false);


        UserBean beanEntity1 = new UserBean();
        beanEntity1.setName("jiang");
        beanEntity1.setPasswd("jiang password");

        UserBean beanEntity2 = new UserBean();
        beanEntity2.setName("hui");
        beanEntity2.setPasswd("hui password");

        UserBean beanEntity3 = new UserBean();
        beanEntity3.setName("123");
        beanEntity3.setPasswd("123 password");

        ArrayList<UserBean> alist = new ArrayList();
        alist.add(beanEntity1);
        alist.add(beanEntity2);
        alist.add(beanEntity3);

        sortListBeans(alist, properties);

        for (UserBean bean : alist) {
            System.out.println("name =" + bean.getName() + ", passwd =" + bean.getPasswd());
        }

    }
项目:elucidate-server    文件:AbstractMessageConverter.java   
@SuppressWarnings("unchecked")
protected Map<String, Object> reorderJsonAttributes(Map<String, Object> jsonMap) {

    ListOrderedMap orderedJsonMap = new ListOrderedMap();
    orderedJsonMap.putAll(jsonMap);

    Object context = orderedJsonMap.get(JSONLDConstants.ATTRIBUTE_CONTEXT);
    if (context != null) {
        orderedJsonMap.remove(JSONLDConstants.ATTRIBUTE_CONTEXT);
        orderedJsonMap.put(0, JSONLDConstants.ATTRIBUTE_CONTEXT, context);
    }

    return orderedJsonMap;
}
项目:gemfirexd-oss    文件:FirebirdModelReader.java   
/**
 * {@inheritDoc}
 */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    // Jaybird is not able to read indices when delimited identifiers are turned on,
    // so we gather the data manually using Firebird's system tables
    final String query =
        "SELECT a.RDB$INDEX_NAME INDEX_NAME, b.RDB$RELATION_NAME TABLE_NAME, b.RDB$UNIQUE_FLAG NON_UNIQUE, " +
        "a.RDB$FIELD_POSITION ORDINAL_POSITION, a.RDB$FIELD_NAME COLUMN_NAME, 3 INDEX_TYPE " +
        "FROM RDB$INDEX_SEGMENTS a, RDB$INDICES b WHERE a.RDB$INDEX_NAME=b.RDB$INDEX_NAME AND b.RDB$RELATION_NAME = ?";

    Map               indices = new ListOrderedMap();
    PreparedStatement stmt    = null;

    try
    {
        stmt = getConnection().prepareStatement(query);

        stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());

        ResultSet indexData = stmt.executeQuery();

        while (indexData.next())
        {
            Map values = readColumns(indexData, getColumnsForIndex());

            // we have to reverse the meaning of the unique flag; also, null means false
            values.put("NON_UNIQUE", (values.get("NON_UNIQUE") == null) || Boolean.FALSE.equals(values.get("NON_UNIQUE")) ? Boolean.TRUE : Boolean.FALSE);
            // and trim the names
            values.put("INDEX_NAME",  ((String)values.get("INDEX_NAME")).trim());
            values.put("TABLE_NAME",  ((String)values.get("TABLE_NAME")).trim());
            values.put("COLUMN_NAME", ((String)values.get("COLUMN_NAME")).trim());
            readIndex(metaData, values, indices);
        }
    }
    finally
    {
        closeStatement(stmt);
    }
    return indices.values();
}
项目:gemfirexd-oss    文件:JdbcModelReader.java   
/**
 * Retrieves the foreign keys of the indicated table.
 *
 * @param metaData  The database meta data
 * @param tableName The name of the table from which to retrieve FK information
 * @return The foreign keys
 */
protected Collection readForeignKeys(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    Map       fks    = new ListOrderedMap();
    ResultSet fkData = null;

    try
    {
        // GemStone changes BEGIN
        //fkData = metaData.getForeignKeys(metaData.escapeForSearch(tableName));

        //The underlying DatabaseMetaData.getImportedKeys does not take the string pattern,
        //so do not need escape the _, see ticket 44911
        fkData = metaData.getForeignKeys(tableName);
        // GemStone changes BEGIN

        while (fkData.next())
        {
            Map values = readColumns(fkData, getColumnsForFK());

            readForeignKey(metaData, values, fks);
        }
    }
    finally
    {
        closeResultSet(fkData);
    }
    return fks.values();
}
项目:gemfirexd-oss    文件:JdbcModelReader.java   
/**
 * Determines the indices for the indicated table.
 * 
 * @param metaData  The database meta data
 * @param tableName The name of the table
 * @return The list of indices
 */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    Map       indices   = new ListOrderedMap();
    ResultSet indexData = null;

    try 
    {
        // GemStone changes BEGIN
        //indexData = metaData.getIndices(metaData.escapeForSearch(tableName), false, false);

        //The underlying DatabaseMetaData.getIndexInfo does not take the string pattern,
        //so do not need escape the _, see ticket 44911
        indexData = metaData.getIndices(tableName, false, false);
        // GemStone changes BEGIN
        while (indexData.next())
        {
            Map values = readColumns(indexData, getColumnsForIndex());

            readIndex(metaData, values, indices);
        }
    }
    finally
    {
        closeResultSet(indexData);
    }
    return indices.values();
}
项目:elpi    文件:TransactionUtil.java   
/**
* Remove the stamp from stack (when resuming)
*/
private static void popTransactionStartStamp() {
    ListOrderedMap map = (ListOrderedMap) suspendedTxStartStamps.get();
    if (map.size() > 0) {
        transactionStartStamp.set((Timestamp) map.remove(map.lastKey()));
    } else {
        Debug.logError("Error in transaction handling - no saved start stamp found - using NOW.", module);
        transactionStartStamp.set(UtilDateTime.nowTimestamp());
    }
}
项目:o3erp    文件:TransactionUtil.java   
/**
* Remove the stamp from stack (when resuming)
*/
private static void popTransactionStartStamp() {
    ListOrderedMap map = (ListOrderedMap) suspendedTxStartStamps.get();
    if (map.size() > 0) {
        transactionStartStamp.set((Timestamp) map.remove(map.lastKey()));
    } else {
        Debug.logError("Error in transaction handling - no saved start stamp found - using NOW.", module);
        transactionStartStamp.set(UtilDateTime.nowTimestamp());
    }
}
项目:Jouve-Project    文件:SpellChecker.java   
public ListOrderedMap suggest(SimpleSearch simpleSearch, Locale locale) {
    ListOrderedMap suggestionsForSentence = new ListOrderedMap();
    String sentence = simpleSearch.getQuery();
    String collectionName = simpleSearch.getCollectionName();
    addSuggestions(sentence, collectionName, suggestionsForSentence, null, locale);
    return suggestionsForSentence;
}
项目:Jouve-Project    文件:StatsCompiler.java   
public String createQuery(ListOrderedMap m_queries) {
    StringBuilder sb = new StringBuilder();
    int i = 0;
    for (Object s : m_queries.keyList()) {
        if ((i > 0) && (m_queries.size() > 1)) {
            sb.append(" ");
        }
        sb.append(s);

        i++;
    }
    return sb.toString();
}
项目:scipio-erp    文件:TransactionUtil.java   
@Override
public Map<Transaction, Timestamp> initialValue() {
    return UtilGenerics.checkMap(new ListOrderedMap());
}
项目:gemfirexd-oss    文件:SqlBuilder.java   
/**
 * Writes a statement that copies the data from the source to the target table. Note
 * that this copies only those columns that are in both tables.
 * Database-specific implementations might redefine this method though it usually
 * suffices to redefine the {@link #writeCastExpression(Column, Column)} method.
 * 
 * @param sourceTable The source table
 * @param targetTable The target table
 */
protected void copyData(Table sourceTable, Table targetTable) throws IOException
{
    ListOrderedMap columns = new ListOrderedMap();

    for (int idx = 0; idx < sourceTable.getColumnCount(); idx++)
    {
        Column sourceColumn = sourceTable.getColumn(idx);
        Column targetColumn = targetTable.findColumn(sourceColumn.getName(),
                                                     getPlatform().isDelimitedIdentifierModeOn());


        if (targetColumn != null)
        {
            columns.put(sourceColumn, targetColumn);
        }
    }

    print("INSERT INTO ");
    printIdentifier(getTableName(targetTable));
    print(" (");
    for (Iterator columnIt = columns.keySet().iterator(); columnIt.hasNext();)
    {
        printIdentifier(getColumnName((Column)columnIt.next()));
        if (columnIt.hasNext())
        {
            print(",");
        }
    }
    print(") SELECT ");
    for (Iterator columnsIt = columns.entrySet().iterator(); columnsIt.hasNext();)
    {
        Map.Entry entry = (Map.Entry)columnsIt.next();

        writeCastExpression((Column)entry.getKey(),
                            (Column)entry.getValue());
        if (columnsIt.hasNext())
        {
            print(",");
        }
    }
    print(" FROM ");
    printIdentifier(getTableName(sourceTable));
    printEndOfStatement();
}
项目:gemfirexd-oss    文件:MckoiModelReader.java   
/**
 * {@inheritDoc}
 */
protected Table readTable(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    // Mckoi does not currently return unique indices in the metadata so we have to query
    // internal tables to get this info
    final String query =
        "SELECT uniqueColumns.column, uniqueColumns.seq_no, uniqueInfo.name" +
        " FROM SYS_INFO.sUSRUniqueColumns uniqueColumns, SYS_INFO.sUSRUniqueInfo uniqueInfo" +
        " WHERE uniqueColumns.un_id = uniqueInfo.id AND uniqueInfo.table = ?";
    final String queryWithSchema =
        query + " AND uniqueInfo.schema = ?";

    Table table = super.readTable(metaData, values);

    if (table != null)
    {
        Map               indices = new ListOrderedMap();
        PreparedStatement stmt    = null;

        try
        {
            stmt = getConnection().prepareStatement(table.getSchema() == null ? query : queryWithSchema);
            stmt.setString(1, table.getName());
            if (table.getSchema() != null)
            {
                stmt.setString(2, table.getSchema());
            }

            ResultSet  resultSet   = stmt.executeQuery();
            Map        indexValues = new HashMap();

            indexValues.put("NON_UNIQUE", Boolean.FALSE);
            while (resultSet.next())
            {
                indexValues.put("COLUMN_NAME",      resultSet.getString(1));
                indexValues.put("ORDINAL_POSITION", Short.valueOf(resultSet.getShort(2)));
                indexValues.put("INDEX_NAME",       resultSet.getString(3));

                readIndex(metaData, indexValues, indices);
            }
        }
        finally
        {
            closeStatement(stmt);
        }

        table.addIndices(indices.values());
    }

    return table;
}
项目:gemfirexd-oss    文件:Oracle8ModelReader.java   
/**
    * {@inheritDoc}
    */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    // Oracle has a bug in the DatabaseMetaData#getIndexInfo method which fails when
    // delimited identifiers are being used
    // Therefore, we're rather accessing the user_indexes table which contains the same info
    // This also allows us to filter system-generated indices which are identified by either
       // having GENERATED='Y' in the query result, or by their index names being equal to the
       // name of the primary key of the table

    final String query =
        "SELECT a.INDEX_NAME, a.INDEX_TYPE, a.UNIQUENESS, b.COLUMN_NAME, b.COLUMN_POSITION FROM USER_INDEXES a, USER_IND_COLUMNS b WHERE " +
        "a.TABLE_NAME=? AND a.GENERATED=? AND a.TABLE_TYPE=? AND a.TABLE_NAME=b.TABLE_NAME AND a.INDEX_NAME=b.INDEX_NAME AND " +
        "a.INDEX_NAME NOT IN (SELECT DISTINCT c.CONSTRAINT_NAME FROM USER_CONSTRAINTS c WHERE c.CONSTRAINT_TYPE=? AND c.TABLE_NAME=a.TABLE_NAME)";
    final String queryWithSchema =
        query.substring(0, query.length() - 1) + " AND c.OWNER LIKE ?) AND a.TABLE_OWNER LIKE ?";

       Map               indices = new ListOrderedMap();
    PreparedStatement stmt    = null;

       try
       {
        stmt = getConnection().prepareStatement(metaData.getSchemaPattern() == null ? query : queryWithSchema);
        stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
        stmt.setString(2, "N");
        stmt.setString(3, "TABLE");
           stmt.setString(4, "P");
        if (metaData.getSchemaPattern() != null)
        {
            stmt.setString(5, metaData.getSchemaPattern().toUpperCase());
               stmt.setString(6, metaData.getSchemaPattern().toUpperCase());
        }

        ResultSet rs     = stmt.executeQuery();
        Map       values = new HashMap();

        while (rs.next())
        {
            values.put("INDEX_NAME",       rs.getString(1));
            values.put("INDEX_TYPE",       Short.valueOf(DatabaseMetaData.tableIndexOther));
            values.put("NON_UNIQUE",       "UNIQUE".equalsIgnoreCase(rs.getString(3)) ? Boolean.FALSE : Boolean.TRUE);
            values.put("COLUMN_NAME",      rs.getString(4));
            values.put("ORDINAL_POSITION", Short.valueOf(rs.getShort(5)));

            readIndex(metaData, values, indices);
        }
       }
       finally
       {
           closeStatement(stmt);
       }
    return indices.values();
}
项目:gemfirexd-oss    文件:SqlBuilder.java   
/**
 * Writes a statement that copies the data from the source to the target table. Note
 * that this copies only those columns that are in both tables.
 * Database-specific implementations might redefine this method though it usually
 * suffices to redefine the {@link #writeCastExpression(Column, Column)} method.
 * 
 * @param sourceTable The source table
 * @param targetTable The target table
 */
protected void copyData(Table sourceTable, Table targetTable) throws IOException
{
    ListOrderedMap columns = new ListOrderedMap();

    for (int idx = 0; idx < sourceTable.getColumnCount(); idx++)
    {
        Column sourceColumn = sourceTable.getColumn(idx);
        Column targetColumn = targetTable.findColumn(sourceColumn.getName(),
                                                     getPlatform().isDelimitedIdentifierModeOn());


        if (targetColumn != null)
        {
            columns.put(sourceColumn, targetColumn);
        }
    }

    print("INSERT INTO ");
    printIdentifier(getTableName(targetTable));
    print(" (");
    for (Iterator columnIt = columns.keySet().iterator(); columnIt.hasNext();)
    {
        printIdentifier(getColumnName((Column)columnIt.next()));
        if (columnIt.hasNext())
        {
            print(",");
        }
    }
    print(") SELECT ");
    for (Iterator columnsIt = columns.entrySet().iterator(); columnsIt.hasNext();)
    {
        Map.Entry entry = (Map.Entry)columnsIt.next();

        writeCastExpression((Column)entry.getKey(),
                            (Column)entry.getValue());
        if (columnsIt.hasNext())
        {
            print(",");
        }
    }
    print(" FROM ");
    printIdentifier(getTableName(sourceTable));
    printEndOfStatement();
}
项目:gemfirexd-oss    文件:MckoiModelReader.java   
/**
 * {@inheritDoc}
 */
protected Table readTable(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    // Mckoi does not currently return unique indices in the metadata so we have to query
    // internal tables to get this info
    final String query =
        "SELECT uniqueColumns.column, uniqueColumns.seq_no, uniqueInfo.name" +
        " FROM SYS_INFO.sUSRUniqueColumns uniqueColumns, SYS_INFO.sUSRUniqueInfo uniqueInfo" +
        " WHERE uniqueColumns.un_id = uniqueInfo.id AND uniqueInfo.table = ?";
    final String queryWithSchema =
        query + " AND uniqueInfo.schema = ?";

    Table table = super.readTable(metaData, values);

    if (table != null)
    {
        Map               indices = new ListOrderedMap();
        PreparedStatement stmt    = null;

        try
        {
            stmt = getConnection().prepareStatement(table.getSchema() == null ? query : queryWithSchema);
            stmt.setString(1, table.getName());
            if (table.getSchema() != null)
            {
                stmt.setString(2, table.getSchema());
            }

            ResultSet  resultSet   = stmt.executeQuery();
            Map        indexValues = new HashMap();

            indexValues.put("NON_UNIQUE", Boolean.FALSE);
            while (resultSet.next())
            {
                indexValues.put("COLUMN_NAME",      resultSet.getString(1));
                indexValues.put("ORDINAL_POSITION", Short.valueOf(resultSet.getShort(2)));
                indexValues.put("INDEX_NAME",       resultSet.getString(3));

                readIndex(metaData, indexValues, indices);
            }
        }
        finally
        {
            closeStatement(stmt);
        }

        table.addIndices(indices.values());
    }

    return table;
}
项目:gemfirexd-oss    文件:Oracle8ModelReader.java   
/**
    * {@inheritDoc}
    */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    // Oracle has a bug in the DatabaseMetaData#getIndexInfo method which fails when
    // delimited identifiers are being used
    // Therefore, we're rather accessing the user_indexes table which contains the same info
    // This also allows us to filter system-generated indices which are identified by either
       // having GENERATED='Y' in the query result, or by their index names being equal to the
       // name of the primary key of the table

    final String query =
        "SELECT a.INDEX_NAME, a.INDEX_TYPE, a.UNIQUENESS, b.COLUMN_NAME, b.COLUMN_POSITION FROM USER_INDEXES a, USER_IND_COLUMNS b WHERE " +
        "a.TABLE_NAME=? AND a.GENERATED=? AND a.TABLE_TYPE=? AND a.TABLE_NAME=b.TABLE_NAME AND a.INDEX_NAME=b.INDEX_NAME AND " +
        "a.INDEX_NAME NOT IN (SELECT DISTINCT c.CONSTRAINT_NAME FROM USER_CONSTRAINTS c WHERE c.CONSTRAINT_TYPE=? AND c.TABLE_NAME=a.TABLE_NAME)";
    final String queryWithSchema =
        query.substring(0, query.length() - 1) + " AND c.OWNER LIKE ?) AND a.TABLE_OWNER LIKE ?";

       Map               indices = new ListOrderedMap();
    PreparedStatement stmt    = null;

       try
       {
        stmt = getConnection().prepareStatement(metaData.getSchemaPattern() == null ? query : queryWithSchema);
        stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
        stmt.setString(2, "N");
        stmt.setString(3, "TABLE");
           stmt.setString(4, "P");
        if (metaData.getSchemaPattern() != null)
        {
            stmt.setString(5, metaData.getSchemaPattern().toUpperCase());
               stmt.setString(6, metaData.getSchemaPattern().toUpperCase());
        }

        ResultSet rs     = stmt.executeQuery();
        Map       values = new HashMap();

        while (rs.next())
        {
            values.put("INDEX_NAME",       rs.getString(1));
            values.put("INDEX_TYPE",       Short.valueOf(DatabaseMetaData.tableIndexOther));
            values.put("NON_UNIQUE",       "UNIQUE".equalsIgnoreCase(rs.getString(3)) ? Boolean.FALSE : Boolean.TRUE);
            values.put("COLUMN_NAME",      rs.getString(4));
            values.put("ORDINAL_POSITION", Short.valueOf(rs.getShort(5)));

            readIndex(metaData, values, indices);
        }
       }
       finally
       {
           closeStatement(stmt);
       }
    return indices.values();
}
项目:r01fb    文件:InsertionOrderedMap.java   
public InsertionOrderedMap(int size) {
    _delegate = ListOrderedMap.decorate(new HashMap<K,V>(size));
}
项目:elpi    文件:TransactionUtil.java   
@Override
public Map<Transaction, Timestamp> initialValue() {
    return UtilGenerics.checkMap(new ListOrderedMap());
}
项目:o3erp    文件:TransactionUtil.java   
@Override
public Map<Transaction, Timestamp> initialValue() {
    return UtilGenerics.checkMap(new ListOrderedMap());
}
项目:Jouve-Project    文件:SpellChecker.java   
public ListOrderedMap suggest(String sentence, String collectionName) {
    ListOrderedMap suggestionsForSentence = new ListOrderedMap();
    addSuggestions(sentence, collectionName, suggestionsForSentence, null, null);
    return suggestionsForSentence;
}
项目:Jouve-Project    文件:SpellChecker.java   
private void addSuggestions(String sentence, String collectionName, ListOrderedMap orderedMap, NamedList<Object> namedList, Locale locale) {
    if (sentence.length() > 250) {
        throw new IllegalArgumentException("String is too long, rejected by spell checker");
    }

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    RecordCollection collection = collectionServices.get(collectionName);
    if (collection != null && collection.isSpellCheckerActive()) {
        String spellCheckerLanguage;
        if (locale != null) {
            spellCheckerLanguage = locale.getLanguage();
        } else {
            spellCheckerLanguage = collection.getSpellCheckerLanguage();
        }
        DICTIONARIES dictionary;
        if (Locale.ENGLISH.getLanguage().equals(spellCheckerLanguage)) {
            dictionary = DICTIONARIES.en_US;
        } else if ("es".equals(spellCheckerLanguage)) {
            dictionary = DICTIONARIES.es_MX;
        } else {
            dictionary = DICTIONARIES.fr_FR;
        }

        Hunspell.Dictionary hunspellDictionary = this.dictionariesMap.get(dictionary);
        String[] words = sentence.split(" ");
        if (words.length > 0) {
            for (int i = 0; i < words.length; i++) {
                String currentWord = words[i];
                currentWord = StringUtils.remove(currentWord, '(');
                currentWord = StringUtils.remove(currentWord, ')');
                   String currentWordWOAccent = AsciiUtils.convertNonAscii(currentWord);
                if (hunspellDictionary.misspelled(currentWord)) {
                    List<String> suggestionsForWord = hunspellDictionary.suggest(currentWord);
                    if (suggestionsForWord.size() > 0) {
                        boolean ignoreSuggestionForWord = false;
                        for (String suggestionForWord : suggestionsForWord) {
                            String sugWOAccent = AsciiUtils.convertNonAscii(suggestionForWord);
                            if (currentWordWOAccent.toLowerCase().equals(sugWOAccent.toLowerCase())) {
                                ignoreSuggestionForWord = true;
                            }
                        }
                        if (orderedMap != null) {
                            orderedMap.put(currentWord, ignoreSuggestionForWord ? null : suggestionsForWord);
                        } else {
                            addNamedList(namedList, currentWord, ! ignoreSuggestionForWord, ignoreSuggestionForWord ? null : suggestionsForWord);
                        }
                    }
                } else {
                    if (orderedMap != null) {
                        orderedMap.put(currentWord, null);
                    } else {
                        addNamedList(namedList, currentWord, false, null);
                    }
                }
            }
        }
    }
}
项目:Jouve-Project    文件:SpellCheckerPanel.java   
private ListOrderedMap getSuggestedSearch() {
    return (ListOrderedMap) getModelObject();
}
项目:apache-ddlutils    文件:SqlBuilder.java   
/**
 * Writes a statement that copies the data from the source to the target table. Note
 * that this copies only those columns that are in both tables.
 * Database-specific implementations might redefine this method though they usually
 * it suffices to redefine the {@link #writeCastExpression(Column, Column)} method.
 * 
 * @param sourceTable The source table
 * @param targetTable The target table
 */
protected void writeCopyDataStatement(Table sourceTable, Table targetTable) throws IOException
{
    ListOrderedMap columns = new ListOrderedMap();

    for (int idx = 0; idx < sourceTable.getColumnCount(); idx++)
    {
        Column sourceColumn = sourceTable.getColumn(idx);
        Column targetColumn = targetTable.findColumn(sourceColumn.getName(),
                                                     getPlatform().isDelimitedIdentifierModeOn());


        if (targetColumn != null)
        {
            columns.put(sourceColumn, targetColumn);
        }
    }

    print("INSERT INTO ");
    printIdentifier(getTableName(targetTable));
    print(" (");
    for (Iterator columnIt = columns.keySet().iterator(); columnIt.hasNext();)
    {
        printIdentifier(getColumnName((Column)columnIt.next()));
        if (columnIt.hasNext())
        {
            print(",");
        }
    }
    print(") SELECT ");
    for (Iterator columnsIt = columns.entrySet().iterator(); columnsIt.hasNext();)
    {
        Map.Entry entry = (Map.Entry)columnsIt.next();

        writeCastExpression((Column)entry.getKey(),
                            (Column)entry.getValue());
        if (columnsIt.hasNext())
        {
            print(",");
        }
    }
    print(" FROM ");
    printIdentifier(getTableName(sourceTable));
    printEndOfStatement();
}
项目:apache-ddlutils    文件:FirebirdModelReader.java   
/**
 * {@inheritDoc}
 */
protected Collection readIndices(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
    // Jaybird is not able to read indices when delimited identifiers are turned on,
    // so we gather the data manually using Firebird's system tables
    Map          indices = new ListOrderedMap();
    StringBuffer query   = new StringBuffer();

    query.append("SELECT a.RDB$INDEX_NAME INDEX_NAME, b.RDB$RELATION_NAME TABLE_NAME, b.RDB$UNIQUE_FLAG NON_UNIQUE,");
    query.append(" a.RDB$FIELD_POSITION ORDINAL_POSITION, a.RDB$FIELD_NAME COLUMN_NAME, 3 INDEX_TYPE");
    query.append(" FROM RDB$INDEX_SEGMENTS a, RDB$INDICES b WHERE a.RDB$INDEX_NAME=b.RDB$INDEX_NAME AND b.RDB$RELATION_NAME = ?");

    PreparedStatement stmt      = getConnection().prepareStatement(query.toString());
    ResultSet         indexData = null;

    stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());

    try 
    {
        indexData = stmt.executeQuery();

        while (indexData.next())
        {
            Map values = readColumns(indexData, getColumnsForIndex());

            // we have to reverse the meaning of the unique flag
            values.put("NON_UNIQUE", Boolean.FALSE.equals(values.get("NON_UNIQUE")) ? Boolean.TRUE : Boolean.FALSE);
            // and trim the names
            values.put("INDEX_NAME",  ((String)values.get("INDEX_NAME")).trim());
            values.put("TABLE_NAME",  ((String)values.get("TABLE_NAME")).trim());
            values.put("COLUMN_NAME", ((String)values.get("COLUMN_NAME")).trim());
            readIndex(metaData, values, indices);
        }
    }
    finally
    {
        if (indexData != null)
        {
            indexData.close();
        }
    }
    return indices.values();
}