001    /*
002     * Created on Mar 26, 2008
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005     * in compliance with the License. You may obtain a copy of the License at
006     *
007     * http://www.apache.org/licenses/LICENSE-2.0
008     *
009     * Unless required by applicable law or agreed to in writing, software distributed under the License
010     * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011     * or implied. See the License for the specific language governing permissions and limitations under
012     * the License.
013     *
014     * Copyright @2008-2010 the original author or authors.
015     */
016    package org.fest.swing.keystroke;
017    
018    import static org.fest.swing.keystroke.KeyStrokeMappings.defaultMappings;
019    
020    import java.util.*;
021    
022    import javax.swing.KeyStroke;
023    
024    /**
025     * Understands a default mapping of characters and <code>{@link KeyStroke}</code>s.
026     *
027     * @author Alex Ruiz
028     */
029    public class DefaultKeyStrokeMappingProvider implements KeyStrokeMappingProvider {
030    
031      /**
032       * Returns the default mapping of characters and <code>{@link KeyStroke}</code>s. This provider will only return
033       * the mappings for following keys:
034       * <ul>
035       * <li>Backspace</li>
036       * <li>Delete</li>
037       * <li>Enter</li>
038       * <li>Escape</li>
039       * <li>Tab</li>
040       * </ul>
041       * @return the default mapping of characters and <code>KeyStroke</code>s
042       */
043      public Collection<KeyStrokeMapping> keyStrokeMappings() {
044        return LazyLoadingSingleton.instance;
045      }
046    
047      private static class LazyLoadingSingleton {
048        static List<KeyStrokeMapping> instance = new ArrayList<KeyStrokeMapping>(defaultMappings());
049      }
050    }