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

The following are Jave code examples for showing how to use splitPreserveAllTokens() 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: cyberduck   File: IRODSHomeFinderService.java   View Source Code Vote up 7 votes
@Override
public Path find() throws BackgroundException {
    final Path home = super.find();
    if(home == DEFAULT_HOME) {
        final String user;
        final Credentials credentials = session.getHost().getCredentials();
        if(StringUtils.contains(credentials.getUsername(), ':')) {
            user = StringUtils.splitPreserveAllTokens(credentials.getUsername(), ':')[1];
        }
        else {
            user = credentials.getUsername();
        }
        return new Path(new StringBuilder()
                .append(Path.DELIMITER).append(session.getRegion())
                .append(Path.DELIMITER).append("home")
                .append(Path.DELIMITER).append(user)
                .toString(), EnumSet.of(Path.Type.directory, Path.Type.volume));
    }
    return home;
}
 
Example 2
Project: cyberduck   File: IRODSSession.java   View Source Code Vote up 6 votes
@Override
public void setUserName(final String input) {
    final String user;
    final AuthScheme scheme;
    if(StringUtils.contains(input, ':')) {
        // Support non default auth scheme (PAM)
        user = StringUtils.splitPreserveAllTokens(input, ':')[1];
        // Defaults to standard if not found
        scheme = AuthScheme.findTypeByString(StringUtils.splitPreserveAllTokens(input, ':')[0]);
    }
    else {
        user = input;
        if(StringUtils.isNotBlank(host.getProtocol().getAuthorization())) {
            scheme = AuthScheme.findTypeByString(host.getProtocol().getAuthorization());
        }
        else {
            // We can default to Standard if not specified
            scheme = AuthScheme.STANDARD;
        }
    }
    super.setUserName(user);
    this.setAuthenticationScheme(scheme);
}
 
Example 3
Project: bootstrap   File: CsvForBean.java   View Source Code Vote up 6 votes
/**
 * Return a list of JPA bean re ad from the given CSV input. Headers are expected. {@inheritDoc}
 */
@Override
public <T> List<T> toBean(final Class<T> beanType, final Reader input) throws IOException {
	final List<T> result = new ArrayList<>();
	final Reader inputProxy = new BufferedReader(input);
	final String line = ((BufferedReader) inputProxy).readLine();
	if (line == null) {
		// No content means no header, no items.
		return result;
	}

	final CsvBeanReader<T> reader = new CsvBeanReader<>(inputProxy, beanType,
			StringUtils.splitPreserveAllTokens(line, CsvReader.DEFAULT_SEPARATOR));

	// Build all instances
	fillList(result, reader);
	return result;
}
 
Example 4
Project: diorite-configs-java8   File: CommentsWriter.java   View Source Code Vote up 6 votes
private void writeComment(String comment) throws IOException
{
    if (comment.isEmpty())
    {
        return;
    }
    String[] strings = StringUtils.splitPreserveAllTokens(comment, '\n');
    int i = 1;
    int size = strings.length;
    for (String string : strings)
    {
        this.writer.write(this.cachedIndent);
        this.writer.write("# ");
        this.writer.write(string);
        this.writeNewLine(true);
    }
    this.lineLock = false;
}
 
Example 5
Project: cyberduck   File: IRODSSession.java   View Source Code Vote up 5 votes
protected String getRegion() {
    if(StringUtils.contains(host.getRegion(), ':')) {
        return StringUtils.splitPreserveAllTokens(host.getRegion(), ':')[0];
    }
    return host.getRegion();
}
 
Example 6
Project: appdomain   File: AppDomainModel.java   View Source Code Vote up 5 votes
protected String[] parseDescriptorNames(String list) {
	String[] header = StringUtils.splitPreserveAllTokens(list,new String(","));
	if (header != null)
		for (int i=0; i < header.length; i++)
			header[i] = header[i].trim();
	return header;
	
}
 
Example 7
Project: remittanceparse   File: RemittanceParser.java   View Source Code Vote up 5 votes
private void parseTsvLine(ArrayList<String> destination, String source) {
    final String[] split = StringUtils.splitPreserveAllTokens(source, "\t");
    for (String s : split) {
        if (StringUtils.startsWith(s, "\"") && StringUtils.endsWith(s, "\"")) {
            destination.add(s.substring(1, s.length() - 1));
        } else
            destination.add(s);
    }

}
 
Example 8
Project: vscrawler   File: Split.java   View Source Code Vote up 5 votes
@Override
protected  String[] split(String str, String separatorChars, int max, boolean preserveAllTokens) {
    if (preserveAllTokens) {
        return StringUtils.splitPreserveAllTokens(str, separatorChars, max);
    } else {
        return StringUtils.split(str, separatorChars, max);
    }
}
 
Example 9
Project: diorite-configs-java8   File: AbstractPropertyAction.java   View Source Code Vote up 5 votes
@SuppressWarnings("MagicNumber")
private static String addMethodIndent(String classCode)
{
    StringBuilder implStr = new StringBuilder(classCode.length() + (classCode.length() / 30));
    for (String s : StringUtils.splitPreserveAllTokens(classCode, '\n'))
    {
        implStr.append("    ").append(s).append("\n");
    }
    return implStr.toString();
}
 
Example 10
Project: diorite-configs-java8   File: GroovyImplementationProvider.java   View Source Code Vote up 5 votes
@SuppressWarnings("MagicNumber")
private static String addMethodIndent(String classCode)
{
    StringBuilder implStr = new StringBuilder(classCode.length() + (classCode.length() / 30));
    for (String s : StringUtils.splitPreserveAllTokens(classCode, '\n'))
    {
        implStr.append("    ").append(s).append("\n");
    }
    return implStr.toString();
}
 
Example 11
Project: diorite-configs-java8   File: GroovyTemplateException.java   View Source Code Vote up 5 votes
@SuppressWarnings("MagicNumber")
static String addDebugLines(String classCode)
{
    StringBuilder implStr = new StringBuilder(classCode.length() + (classCode.length() / 30));
    int i = 1;
    for (String s : StringUtils.splitPreserveAllTokens(classCode, '\n'))
    {
        implStr.append("/* ").append(i++).append(" */").append(s).append("\n");
    }
    return implStr.toString();
}
 
Example 12
Project: cyberduck   File: IRODSSession.java   View Source Code Vote up 4 votes
protected String getResource() {
    if(StringUtils.contains(host.getRegion(), ':')) {
        return StringUtils.splitPreserveAllTokens(host.getRegion(), ':')[1];
    }
    return StringUtils.EMPTY;
}
 
Example 13
Project: plugin-id-ldap   File: UserLdapRepository.java   View Source Code Vote up 3 votes
/**
 * Extract the {@link Date}, author, and the previous company from the locked attribute if available and matched
 * to the
 * expected {@link UserLdapRepository#lockedValue}
 * 
 * @param user
 *            The user to update.
 * @param lockedValue
 *            The locked value flag. May be <code>null</code>.
 */
private void fillLockedData(final SimpleUserOrg user, final String lockedValue) {
	if (StringUtils.startsWith(lockedValue, UserLdapRepository.this.lockedValue)) {
		// A locked account
		final String[] fragments = StringUtils.splitPreserveAllTokens(lockedValue, '|');
		user.setLocked(new Date(Long.parseLong(fragments[1])));
		user.setLockedBy(fragments[2]);
		user.setIsolated(StringUtils.defaultIfEmpty(fragments[3], null));
	}
}