当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.stripTrailingSeparator方法代码示例

本文整理汇总了Java中org.apache.camel.util.FileUtil.stripTrailingSeparator方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.stripTrailingSeparator方法的具体用法?Java FileUtil.stripTrailingSeparator怎么用?Java FileUtil.stripTrailingSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.FileUtil的用法示例。


在下文中一共展示了FileUtil.stripTrailingSeparator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureMoveOrPreMoveExpression

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
/**
 * Strategy to configure the move, preMove, or moveExisting option based on a String input.
 *
 * @param expression the original string input
 * @return configured string or the original if no modifications is needed
 */
protected String configureMoveOrPreMoveExpression(String expression) {
    // if the expression already have ${ } placeholders then pass it unmodified
    if (StringHelper.hasStartToken(expression, "simple")) {
        return expression;
    }

    // remove trailing slash
    expression = FileUtil.stripTrailingSeparator(expression);

    StringBuilder sb = new StringBuilder();

    // if relative then insert start with the parent folder
    if (!isAbsolute(expression)) {
        sb.append("${file:parent}");
        sb.append(getFileSeparator());
    }
    // insert the directory the end user provided
    sb.append(expression);
    // append only the filename (file:name can contain a relative path, so we must use onlyname)
    sb.append(getFileSeparator());
    sb.append("${file:onlyname}");

    return sb.toString();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:GenericFileEndpoint.java

示例2: pollDirectory

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@Override
protected boolean pollDirectory(String fileName, List<GenericFile<ChannelSftp.LsEntry>> fileList, int depth) {
    String currentDir = null;
    if (isStepwise()) {
        // must remember current dir so we stay in that directory after the poll
        currentDir = operations.getCurrentDirectory();
    }

    // strip trailing slash
    fileName = FileUtil.stripTrailingSeparator(fileName);

    boolean answer = doPollDirectory(fileName, null, fileList, depth);
    if (currentDir != null) {
        operations.changeCurrentDirectory(currentDir);
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:SftpConsumer.java

示例3: pollDirectory

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@Override
protected boolean pollDirectory(String fileName, List<GenericFile<FTPFile>> fileList, int depth) {
    String currentDir = null;
    if (isStepwise()) {
        // must remember current dir so we stay in that directory after the poll
        currentDir = operations.getCurrentDirectory();
    }

    // strip trailing slash
    fileName = FileUtil.stripTrailingSeparator(fileName);

    boolean answer = doPollDirectory(fileName, null, fileList, depth);
    if (currentDir != null) {
        operations.changeCurrentDirectory(currentDir);
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:FtpConsumer.java

示例4: buildUrl

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
private static String buildUrl(String scheme, String hostname, Object port, String path, String uri) {
    // build together from component level and given uri that has additional context path to append
    String build = scheme + "://" + hostname;
    if (port != null) {
        build += ":" + port;
    }
    if (path != null) {
        build = FileUtil.stripTrailingSeparator(build);
        build += "/" + path;
    }

    String query = null;
    if (uri != null && uri.contains("?")) {
        query = StringHelper.after(uri, "?");
        uri = StringHelper.before(uri, "?");
        uri = StringHelper.after(uri, "://");
    }

    // remaining is to be appending
    if (uri != null) {
        build = FileUtil.stripTrailingSeparator(build);
        build += "/" + uri;
    }

    if (query != null) {
        build += "?" + query;
    }
    return build;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:30,代码来源:HttpComponent.java

示例5: createEndpoint

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    RestEndpoint answer = new RestEndpoint(uri, this);
    setProperties(answer, parameters);
    answer.setParameters(parameters);

    if (!remaining.contains(":")) {
        throw new IllegalArgumentException("Invalid syntax. Must be rest:method:path[:uriTemplate] where uriTemplate is optional");
    }

    String method = ObjectHelper.before(remaining, ":");
    String s = ObjectHelper.after(remaining, ":");

    String path;
    String uriTemplate;
    if (s != null && s.contains(":")) {
        path = ObjectHelper.before(s, ":");
        uriTemplate = ObjectHelper.after(s, ":");
    } else {
        path = s;
        uriTemplate = null;
    }

    // remove trailing slashes
    path = FileUtil.stripTrailingSeparator(path);
    uriTemplate = FileUtil.stripTrailingSeparator(uriTemplate);

    answer.setMethod(method);
    answer.setPath(path);
    answer.setUriTemplate(uriTemplate);

    // if no explicit component name was given, then fallback and use default configured component name
    if (answer.getComponentName() == null && getCamelContext().getRestConfiguration() != null) {
        answer.setComponentName(getCamelContext().getRestConfiguration().getComponent());
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:RestComponent.java

示例6: asRemoteFile

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
private RemoteFile<ChannelSftp.LsEntry> asRemoteFile(String absolutePath, ChannelSftp.LsEntry file, String charset) {
    RemoteFile<ChannelSftp.LsEntry> answer = new RemoteFile<ChannelSftp.LsEntry>();

    answer.setCharset(charset);
    answer.setEndpointPath(endpointPath);
    answer.setFile(file);
    answer.setFileNameOnly(file.getFilename());
    answer.setFileLength(file.getAttrs().getSize());
    answer.setLastModified(file.getAttrs().getMTime() * 1000L);
    answer.setHostname(((RemoteFileConfiguration) endpoint.getConfiguration()).getHost());
    answer.setDirectory(file.getAttrs().isDir());

    // absolute or relative path
    boolean absolute = FileUtil.hasLeadingSeparator(absolutePath);
    answer.setAbsolute(absolute);

    // create a pseudo absolute name
    String dir = FileUtil.stripTrailingSeparator(absolutePath);
    String absoluteFileName = FileUtil.stripLeadingSeparator(dir + "/" + file.getFilename());
    // if absolute start with a leading separator otherwise let it be relative
    if (absolute) {
        absoluteFileName = "/" + absoluteFileName;
    }
    answer.setAbsoluteFilePath(absoluteFileName);

    // the relative filename, skip the leading endpoint configured path
    String relativePath = ObjectHelper.after(absoluteFileName, endpointPath);
    // skip trailing /
    relativePath = FileUtil.stripLeadingSeparator(relativePath);
    answer.setRelativeFilePath(relativePath);

    // the file name should be the relative path
    answer.setFileName(answer.getRelativeFilePath());

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:37,代码来源:SftpConsumer.java

示例7: asRemoteFile

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
private RemoteFile<FTPFile> asRemoteFile(String absolutePath, FTPFile file, String charset) {
    RemoteFile<FTPFile> answer = new RemoteFile<FTPFile>();

    answer.setCharset(charset);
    answer.setEndpointPath(endpointPath);
    answer.setFile(file);
    answer.setFileNameOnly(file.getName());
    answer.setFileLength(file.getSize());
    answer.setDirectory(file.isDirectory());
    if (file.getTimestamp() != null) {
        answer.setLastModified(file.getTimestamp().getTimeInMillis());
    }
    answer.setHostname(((RemoteFileConfiguration) endpoint.getConfiguration()).getHost());

    // absolute or relative path
    boolean absolute = FileUtil.hasLeadingSeparator(absolutePath);
    answer.setAbsolute(absolute);

    // create a pseudo absolute name
    String dir = FileUtil.stripTrailingSeparator(absolutePath);
    String absoluteFileName = FileUtil.stripLeadingSeparator(dir + "/" + file.getName());
    // if absolute start with a leading separator otherwise let it be relative
    if (absolute) {
        absoluteFileName = "/" + absoluteFileName;
    }
    answer.setAbsoluteFilePath(absoluteFileName);

    // the relative filename, skip the leading endpoint configured path
    String relativePath = ObjectHelper.after(absoluteFileName, endpointPath);
    // skip leading /
    relativePath = FileUtil.stripLeadingSeparator(relativePath);
    answer.setRelativeFilePath(relativePath);

    // the file name should be the relative path
    answer.setFileName(answer.getRelativeFilePath());

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:FtpConsumer.java

示例8: buildUrl

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
public static String buildUrl(String path1, String path2) {
    String s1 = FileUtil.stripTrailingSeparator(path1);
    String s2 = FileUtil.stripLeadingSeparator(path2);
    if (s1 != null && s2 != null) {
        return s1 + "/" + s2;
    } else if (path1 != null) {
        return path1;
    } else {
        return path2;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:SwaggerHelper.java

示例9: doCreateConsumer

import org.apache.camel.util.FileUtil; //导入方法依赖的package包/类
Consumer doCreateConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate,
                          String consumes, String produces, RestConfiguration configuration, Map<String, Object> parameters, boolean api) throws Exception {

    String path = basePath;
    if (uriTemplate != null) {
        // make sure to avoid double slashes
        if (uriTemplate.startsWith("/")) {
            path = path + uriTemplate;
        } else {
            path = path + "/" + uriTemplate;
        }
    }
    path = FileUtil.stripLeadingSeparator(path);

    RestConfiguration config = configuration;
    if (config == null) {
        config = camelContext.getRestConfiguration("spark-rest", true);
    }

    Map<String, Object> map = new HashMap<String, Object>();
    if (consumes != null) {
        map.put("accept", consumes);
    }

    // setup endpoint options
    if (config.getEndpointProperties() != null && !config.getEndpointProperties().isEmpty()) {
        map.putAll(config.getEndpointProperties());
    }

    if (ObjectHelper.isNotEmpty(path)) {
        // spark-rest uses :name syntax instead of {name} so we need to replace those
        Matcher matcher = pattern.matcher(path);
        path = matcher.replaceAll(":$1");
    }

    // prefix path with context-path if configured in rest-dsl configuration
    String contextPath = config.getContextPath();
    if (ObjectHelper.isNotEmpty(contextPath)) {
        contextPath = FileUtil.stripTrailingSeparator(contextPath);
        contextPath = FileUtil.stripLeadingSeparator(contextPath);
        if (ObjectHelper.isNotEmpty(contextPath)) {
            path = contextPath + "/" + path;
        }
    }

    String url;
    if (api) {
        url = "spark-rest:%s:%s?matchOnUriPrefix=true";
    } else {
        url = "spark-rest:%s:%s";
    }

    url = String.format(url, verb, path);

    String query = URISupport.createQueryString(map);
    if (!query.isEmpty()) {
        url = url + "?" + query;
    }

    // get the endpoint
    SparkEndpoint endpoint = camelContext.getEndpoint(url, SparkEndpoint.class);
    setProperties(camelContext, endpoint, parameters);

    // configure consumer properties
    Consumer consumer = endpoint.createConsumer(processor);
    if (config.isEnableCORS()) {
        // if CORS is enabled then configure that on the spark consumer
        if (config.getConsumerProperties() == null) {
            config.setConsumerProperties(new HashMap<String, Object>());
        }
        config.getConsumerProperties().put("enableCors", true);
    }
    if (config.getConsumerProperties() != null && !config.getConsumerProperties().isEmpty()) {
        setProperties(camelContext, consumer, config.getConsumerProperties());
    }
    return consumer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:78,代码来源:SparkComponent.java


注:本文中的org.apache.camel.util.FileUtil.stripTrailingSeparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。