SHL-61 - Remove unused Hint classes

This commit is contained in:
Mark Pollack
2012-09-19 14:27:35 -04:00
parent e2e9f965ac
commit ea25910fce
5 changed files with 0 additions and 181 deletions

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2011-2012 the original author or authors.
*
* Licensed 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.springframework.shell.commands;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.stereotype.Component;
@Component
public class HintCommands implements CommandMarker {
// Fields
@Autowired private HintOperations hintOperations;
//TODO: figure out how to provide hint
//@CliCommand(value = "hint", help = "Provides step-by-step hints and context-sensitive guidance")
public String hint(
@CliOption(key = { "topic", "" }, mandatory = false, unspecifiedDefaultValue = "", optionContext = "disable-string-converter,topics", help = "The topic for which advice should be provided") final String topic) {
return hintOperations.hint(topic);
}
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright 2011-2012 the original author or authors.
*
* Licensed 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.springframework.shell.commands;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.Completion;
import org.springframework.shell.core.Converter;
import org.springframework.shell.core.MethodTarget;
import org.springframework.stereotype.Component;
/**
* {@link Converter} for {@link String} that understands the "topics" option context.
*
* @author Ben Alex
* @since 1.1
*/
@Component
public class HintConverter implements Converter<String> {
// Fields
@Autowired private HintOperations hintOperations;
public String convertFromText(final String value, final Class<?> requiredType, final String optionContext) {
return value;
}
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, final String existingData, final String optionContext, final MethodTarget target) {
for (String currentTopic : hintOperations.getCurrentTopics()) {
completions.add(new Completion(currentTopic));
}
return false;
}
public boolean supports(final Class<?> requiredType, final String optionContext) {
return String.class.isAssignableFrom(requiredType) && optionContext.contains("topics");
}
}

View File

@@ -1,25 +0,0 @@
/*
* Copyright 2011-2012 the original author or authors.
*
* Licensed 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.springframework.shell.commands;
import java.util.SortedSet;
public interface HintOperations {
String hint(String topic);
SortedSet<String> getCurrentTopics();
}

View File

@@ -1,65 +0,0 @@
/*
* Copyright 2011-2012 the original author or authors.
*
* Licensed 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.springframework.shell.commands;
import java.util.Enumeration;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.SortedSet;
import java.util.TreeSet;
import org.springframework.shell.core.AbstractShell;
import org.springframework.shell.support.util.OsUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Component
public class ResourceBundleHintOperations implements HintOperations {
private static ResourceBundle bundle = ResourceBundle.getBundle(HintCommands.class.getName());
public String hint(String topic) {
if (!StringUtils.hasText(topic)) {
topic = determineTopic();
}
try {
String message = bundle.getString(topic);
return message.replace("\r", OsUtils.LINE_SEPARATOR).replace("${completion_key}", AbstractShell.completionKeys);
} catch (MissingResourceException exception) {
return "Cannot find topic '" + topic + "'";
}
}
public SortedSet<String> getCurrentTopics() {
SortedSet<String> result = new TreeSet<String>();
String topic = determineTopic();
if ("general".equals(topic)) {
for (Enumeration<String> keys = bundle.getKeys(); keys.hasMoreElements();) {
result.add(keys.nextElement());
}
// result.addAll(bundle.keySet()); ResourceBundle.keySet() method in JDK 6+
} else {
result.add(topic);
}
return result;
}
private String determineTopic() {
return "start";
//return "general";
}
}

View File

@@ -1,3 +0,0 @@
topics=
general=
start=Welcome to the Spring Shell! To start your journey.....