// Path: gshell-api/src/main/java/org/apache/geronimo/gshell/command/MessageSource.java
// public interface MessageSource
// {
//     String getMessage(String code);
// 
//     String getMessage(String code, Object... args);
// }
// 
// Path: gshell-core/src/main/java/org/apache/geronimo/gshell/command/MessageSourceImpl.java
// public class MessageSourceImpl
//     implements MessageSource
// {
//     //
//     // TODO: Add a global message set that is overridden by command messages
//     //
//     
//     private final ResourceBundle bundle;
// 
//     public MessageSourceImpl(final String name) {
//         if (name == null) {
//             throw new NullArgumentException("name");
//         }
// 
//         bundle = ResourceBundle.getBundle(name);
//     }
// 
//     public String getMessage(final String code) {
//         return bundle.getString(code);
//     }
// 
//     public String getMessage(final String code, final Object... args) {
//         String format = getMessage(code);
// 
//         StringBuilder sb = new StringBuilder();
//         Formatter f = new Formatter(sb);
//         
//         f.format(format, args);
// 
//         return sb.toString();
//     }
// }


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gshell.command.MessageSource;
import org.apache.geronimo.gshell.command.MessageSourceImpl;
import jline.CompletionHandler;
import jline.ConsoleReader;
import jline.CursorBuffer;
import java.util.List;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.ArrayList;
import java.io.IOException;
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.geronimo.gshell;





//
// NOTE: Based on jline.CandidateListCompletionHandler.  CLCH that comes with
//       jLine 0.9.5 has a bug that never displays the completion list.  When that
//       is fixed, then this class can be removed.
//

/**
 * A candindate list completion handler (that actually works).
 *
 * <p>
 * Follows the style of Bash.
 *
 * @version $Rev$ $Date$
 */
public class CompletionHandlerImpl
    implements CompletionHandler
{
    private static final Log log = LogFactory.getLog(CompletionHandlerImpl.class);

// Path: gshell-api/src/main/java/org/apache/geronimo/gshell/command/MessageSource.java
// public interface MessageSource
// {
//     String getMessage(String code);
// 
//     String getMessage(String code, Object... args);
// }
// 
// Path: gshell-core/src/main/java/org/apache/geronimo/gshell/command/MessageSourceImpl.java
// public class MessageSourceImpl
//     implements MessageSource
// {
//     //
//     // TODO: Add a global message set that is overridden by command messages
//     //
//     
//     private final ResourceBundle bundle;
// 
//     public MessageSourceImpl(final String name) {
//         if (name == null) {
//             throw new NullArgumentException("name");
//         }
// 
//         bundle = ResourceBundle.getBundle(name);
//     }
// 
//     public String getMessage(final String code) {
//         return bundle.getString(code);
//     }
// 
//     public String getMessage(final String code, final Object... args) {
//         String format = getMessage(code);
// 
//         StringBuilder sb = new StringBuilder();
//         Formatter f = new Formatter(sb);
//         
//         f.format(format, args);
// 
//         return sb.toString();
//     }
// }


// Path: gshell-core/src/main/java/org/apache/geronimo/gshell/CompletionHandlerImpl.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gshell.command.MessageSource;
import org.apache.geronimo.gshell.command.MessageSourceImpl;
import jline.CompletionHandler;
import jline.ConsoleReader;
import jline.CursorBuffer;
import java.util.List;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.ArrayList;
import java.io.IOException;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.geronimo.gshell;





//
// NOTE: Based on jline.CandidateListCompletionHandler.  CLCH that comes with
//       jLine 0.9.5 has a bug that never displays the completion list.  When that
//       is fixed, then this class can be removed.
//

/**
 * A candindate list completion handler (that actually works).
 *
 * <p>
 * Follows the style of Bash.
 *
 * @version $Rev$ $Date$
 */
public class CompletionHandlerImpl
    implements CompletionHandler
{
    private static final Log log = LogFactory.getLog(CompletionHandlerImpl.class);

    private static MessageSource messages = new MessageSourceImpl(CompletionHandlerImpl.class.getName());