All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.schoolwow.util.module.query.resource.flow.GetFileNameFlow Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package cn.schoolwow.util.module.query.resource.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.module.query.resource.flow.walkResource.common.SetUrlFileFlow;

import java.io.File;
import java.net.URL;

public class GetFileNameFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        getFromFile(flowContext);
        getFromJar(flowContext);
    }

    @Override
    public String name() {
        return "获取资源文件名称";
    }

    private void getFromFile(FlowContext flowContext){
        File file = (File) flowContext.getData("file");
        if(null==file){
            return;
        }
        String fileName = file.getName();
        flowContext.putReturnData("fileName" ,fileName);
        flowContext.brokenCurrentFlow("从文件获取");
    }

    private void getFromJar(FlowContext flowContext){
        flowContext.executeFlowList(new SetUrlFileFlow());
        String urlFile = (String) flowContext.checkData("urlFile");

        String fileName = urlFile.substring(urlFile.lastIndexOf("/")+1);
        flowContext.putReturnData("fileName" ,fileName);
        flowContext.brokenCurrentFlow("从jar文件获取");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy