Java Code Examples for org.apache.commons.lang3.StringUtils.stripEnd()

The following are Jave code examples for showing how to use stripEnd() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: galop   File: HeaderParserImpl.java   View Source Code Vote up 6 votes
private String parseFieldName(final String line, final int colonIndex, final boolean request)
        throws InvalidHttpHeaderException {

    String name = line.substring(0, colonIndex).toLowerCase(Locale.ENGLISH);

    if (name.isEmpty()) {
        throw new InvalidHttpHeaderException("Invalid HTTP header field: Empty header field name.");
    }

    if (Character.isWhitespace(name.charAt(name.length() - 1))) {

        if (request) {
            throw new InvalidHttpHeaderException("Invalid HTTP header field: "
                    + "No whitespace is allowed between the header field-name and colon.");
        } else {
            name = StringUtils.stripEnd(name, null);
        }

    }

    return name;

}
 
Example 2
Project: gaffer-doc   File: JavaSourceUtil.java   View Source Code Vote up 6 votes
public static String getRawJavaSnippet(final Class<?> clazz, final String modulePath, final String marker, final String start, final String end) {
    String javaCode = getRawJava(clazz.getName(), modulePath);
    final int markerIndex = javaCode.indexOf(marker);
    if (markerIndex < 0) {
        throw new IllegalArgumentException("Cannot find java snippet for: " + clazz.getName() + " " + marker);
    }

    javaCode = javaCode.substring(markerIndex);
    javaCode = javaCode.substring(javaCode.indexOf(start) + start.length());
    javaCode = javaCode.substring(0, javaCode.indexOf(end));
    javaCode = StringUtils.stripEnd(javaCode, " " + NEW_LINE);

    // Remove indentation
    final String trimmedJavaCode = javaCode.trim();
    final int leadingSpaces = javaCode.indexOf(trimmedJavaCode);
    if (leadingSpaces > 0) {
        final String spacesRegex = NEW_LINE + StringUtils.repeat(" ", leadingSpaces);
        javaCode = trimmedJavaCode.replace(spacesRegex, NEW_LINE);
    }

    return javaCode;
}
 
Example 3
Project: gitplex-mit   File: GitPlex.java   View Source Code Vote up 6 votes
public String guessServerUrl() {
	String hostName;
	try {
		hostName = InetAddress.getLocalHost().getHostName();
	} catch (UnknownHostException e) {
		throw new RuntimeException(e);
	}
	
	String serverUrl;
	if (serverConfig.getHttpPort() != 0)
		serverUrl = "http://" + hostName + ":" + serverConfig.getHttpPort();
	else 
		serverUrl = "https://" + hostName + ":" + serverConfig.getSslConfig().getPort();

	return StringUtils.stripEnd(serverUrl, "/");
}
 
Example 4
Project: uroborosql   File: SqlLoaderImpl.java   View Source Code Vote up 5 votes
/**
 * SQL文末尾の"/"を取り除く<br>
 *
 * @param sql SQL文字列
 * @return トリム後文字列
 */
private String trimSlash(final String sql) {
	String trimedSql = sql.trim();
	if (trimedSql.endsWith(PATH_SEPARATOR) && !trimedSql.endsWith("*/")) {
		return StringUtils.stripEnd(trimedSql, PATH_SEPARATOR);
	} else {
		return sql;
	}
}
 
Example 5
Project: gitplex-mit   File: Blame.java   View Source Code Vote up 5 votes
@Override
public String toString() {
	StringBuilder builder = new StringBuilder();
	builder.append(commit.getHash()).append(": ");
	for (Range range: ranges) 
		builder.append(range).append(", ");
	
	return StringUtils.stripEnd(builder.toString(), ", ");
}
 
Example 6
Project: WebAndAppUITesting   File: FrameTask.java   View Source Code Vote up 4 votes
public FrameTask() {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(true, getFile());
	}
 
Example 7
Project: WebAndAppUITesting   File: FrameTask.java   View Source Code Vote up 4 votes
public FrameTask(String eventName) {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(true, getFile());
		FrameTask.eventName = eventName;
	}
 
Example 8
Project: WebAndAppUITesting   File: FrameTask.java   View Source Code Vote up 4 votes
public FrameTask(boolean bWriteFile) {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(bWriteFile, getFile());
	}
 
Example 9
Project: WebAndAppUITesting   File: FrameTask.java   View Source Code Vote up 4 votes
public FrameTask(boolean bWriteFile, String filename) {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(bWriteFile, filename);
	}
 
Example 10
Project: WebAndAppUITesting   File: CpuTask.java   View Source Code Vote up 4 votes
public CpuTask() {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(true, getFile());
	}
 
Example 11
Project: WebAndAppUITesting   File: CpuTask.java   View Source Code Vote up 4 votes
public CpuTask(String eventName) {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(true, getFile());
		CpuTask.eventName = eventName;
	}
 
Example 12
Project: WebAndAppUITesting   File: CpuTask.java   View Source Code Vote up 4 votes
public CpuTask(boolean bWriteFile) {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(bWriteFile, getFile());
	}
 
Example 13
Project: gitplex-mit   File: SystemSetting.java   View Source Code Vote up 4 votes
@Override
public boolean isValid(ConstraintValidatorContext context) {
	if (serverUrl != null)
		serverUrl = StringUtils.stripEnd(serverUrl, "/\\");
	return true;
}
 
Example 14
Project: WebAndAppUITesting   File: FlowTask.java   View Source Code Vote up 4 votes
public FlowTask() {

		String fileName = Thread.currentThread().getStackTrace()[2].getFileName();
		file = StringUtils.stripEnd(fileName, ".java") + file;
		initFields(true, getFile());
	}
 
Example 15
Project: WebAndAppUITesting   File: FlowTask.java   View Source Code Vote up 4 votes
public FlowTask(boolean bWriteFile) {

		String fileName = Thread.currentThread().getStackTrace()[2].getFileName();
		file = StringUtils.stripEnd(fileName, ".java") + file;
		initFields(bWriteFile, getFile());
	}
 
Example 16
Project: WebAndAppUITesting   File: FlowTask.java   View Source Code Vote up 4 votes
public FlowTask(boolean bWriteFile, String filename) {

		String fileName = Thread.currentThread().getStackTrace()[2].getFileName();
		file = StringUtils.stripEnd(fileName, ".java") + file;
		initFields(bWriteFile, filename);
	}
 
Example 17
Project: WebAndAppUITesting   File: MemTask.java   View Source Code Vote up 4 votes
public MemTask() {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(true, getFile());
	}
 
Example 18
Project: WebAndAppUITesting   File: MemTask.java   View Source Code Vote up 4 votes
public MemTask(boolean bWriteFile, String filename) {

		file = StringUtils.stripEnd(getfileName(), ".java") + file;
		initFields(bWriteFile, filename);
	}
 
Example 19
Project: dcsi   File: ForgerockUserDao2.java   View Source Code Vote up 4 votes
public ForgerockUserDao2(String serverUrl, String serverUsername, String serverPassword) {
  this.serverUrl = StringUtils.stripEnd(serverUrl, "/");
  this.serverUsername = serverUsername;
  this.serverPassword = serverPassword;
}
 
Example 20
Project: sponge   File: DefaultInteractiveMode.java   View Source Code Vote up 4 votes
protected boolean iteration(InteractiveModeConsole reader, ScriptKnowledgeBaseInterpreter scriptInterpreter) throws IOException {
    StringBuffer commandBuffer = new StringBuffer();
    while (true) {
        if (!engine.isRunning()) {
            return false;
        }

        String command = null;
        try {
            command = reader.readLine();
        } catch (IOException e) {
            handleException("readLine", e);
            return false;
        }

        if (command == null) {
            return false;
        }

        command = StringUtils.stripEnd(command, null);

        if (StringUtils.equalsAny(command.trim(), InteractiveModeConstants.EXIT_COMMAND, InteractiveModeConstants.QUIT_COMMAND)) {
            return false;
        }

        boolean isMultiLineStatement = command.endsWith(InteractiveModeConstants.LINE_BREAK);
        if (isMultiLineStatement) {
            command = StringUtils.removeEnd(command, InteractiveModeConstants.LINE_BREAK);
        }

        commandBuffer.append(command);

        if (isMultiLineStatement) {
            commandBuffer.append(System.lineSeparator());
        } else {
            break;
        }
    }

    if (engine.isRunning()) {
        scriptInterpreter.eval(commandBuffer.toString());
        return true;
    } else {
        return false;
    }
}