net.sf.jcmdlineparser.strategy.escape.StringHandlerEscape Maven / Gradle / Ivy
/**********************************************************************
Copyright (c) 2009-2010 Alexander Kerner. All rights reserved.
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 net.sf.jcmdlineparser.strategy.escape;
import net.sf.jcmdlineparser.strategy.StrategyRules;
/**
*
*
* TODO description
*
*
*
* TODO example
*
*
* @version 2010-08-27
*
*/
class StringHandlerEscape implements StringHandler {
private StrategyRules rules;
public StringHandlerEscape(StrategyRules rules) {
this.rules = rules;
}
public String handleString(String string) {
final StringBuilder sb = new StringBuilder();
// look at string from other side
string = new StringBuilder(string).reverse().toString();
// find start point
int start = 0;
for(int i = 0; i < string.length(); i++){
if(rules.isEscapeChar(string.charAt(i))){
start = i+1;
break;
}
}
for(int i = start; i < string.length(); i++){
final char c = string.charAt(i);
sb.append(c);
}
return sb.reverse().toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy