!7 添加注释

Merge pull request !7 from 邱收/master
This commit is contained in:
小东 2019-08-02 11:15:55 +08:00 committed by Gitee
commit 7e35439cc3
23 changed files with 135 additions and 2 deletions

View File

@ -10,8 +10,9 @@ import org.spiderflow.core.context.SpiderContext;
import org.spiderflow.core.model.SpiderNode;
import org.spiderflow.core.utils.DataSourceUtils;
import org.springframework.stereotype.Component;
/**
* 数据源执行器
* 定义数据源执行器
* @author jmxd
*
*/

View File

@ -12,6 +12,11 @@ import org.spiderflow.core.model.SpiderNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 函数执行器
* @author Administrator
*
*/
@Component
public class FunctionExecutor implements Executor{

View File

@ -13,6 +13,11 @@ import org.spiderflow.core.model.SpiderOutput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 输出执行器
* @author Administrator
*
*/
@Component
public class OutputExecutor implements Executor{

View File

@ -15,6 +15,11 @@ import org.spiderflow.web.service.SpiderFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 子流程执行器
* @author Administrator
*
*/
@Component
public class ProcessExecutor implements Executor{

View File

@ -17,6 +17,11 @@ import org.spiderflow.core.model.SpiderNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 请求执行器
* @author Administrator
*
*/
@Component
public class RequestExecutor implements Executor{

View File

@ -6,6 +6,11 @@ import org.spiderflow.core.context.SpiderContext;
import org.spiderflow.core.model.SpiderNode;
import org.springframework.stereotype.Component;
/**
* 开始执行器
* @author Administrator
*
*/
@Component
public class StartExecutor implements Executor{

View File

@ -12,6 +12,11 @@ import org.spiderflow.core.model.SpiderNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 定义变量执行器
* @author Administrator
*
*/
@Component
public class VariableExecutor implements Executor{

View File

@ -7,6 +7,11 @@ import org.springframework.stereotype.Component;
import freemarker.template.TemplateModelException;
/**
* 封装正则表达式的选择器方法类
* @author Administrator
*
*/
@Component
public class RegxFunction extends FreemarkerTemplateMethodModel{

View File

@ -7,6 +7,11 @@ import org.springframework.stereotype.Component;
import freemarker.template.TemplateModelException;
/**
* 封装多个正则表达式的选择器方法类
* @author Administrator
*
*/
@Component
public class RegxsFunction extends FreemarkerTemplateMethodModel{

View File

@ -9,6 +9,11 @@ import org.springframework.stereotype.Component;
import freemarker.template.TemplateModelException;
/**
* 封装选择器(Selector)的选择器(Freemarker)方法类
* @author Administrator
*
*/
@Component
public class SelectorFunction extends FreemarkerTemplateMethodModel{

View File

@ -9,6 +9,11 @@ import org.springframework.stereotype.Component;
import freemarker.template.TemplateModelException;
/**
* 封装多个选择器(Selector)的选择器(Freemarker)方法类
* @author Administrator
*
*/
@Component
public class SelectorsFunction extends FreemarkerTemplateMethodModel{

View File

@ -9,6 +9,11 @@ import org.springframework.stereotype.Component;
import freemarker.template.TemplateModelException;
/**
* 封装路径表达式(XML路径语言)的选择器方法类
* @author Administrator
*
*/
@Component
public class XPathFunction extends FreemarkerTemplateMethodModel{

View File

@ -9,6 +9,11 @@ import org.springframework.stereotype.Component;
import freemarker.template.TemplateModelException;
/**
* 封装多个路径表达式(XML路径语言)的选择器方法类
* @author Administrator
*
*/
@Component
public class XPathsFunction extends FreemarkerTemplateMethodModel{

View File

@ -2,6 +2,11 @@ package org.spiderflow.core.freemarker.functions.utils;
import org.apache.commons.codec.binary.Base64;
/**
* 字符串内容和Base64互相转换 工具类 防止NPE
* @author Administrator
*
*/
public class Base64FunctionUtils {
public static String encode(byte[] bytes){

View File

@ -6,6 +6,11 @@ import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
/**
* 时间获取/格式化 工具类 防止NPE 默认格式(yyyy-MM-dd HH:mm:ss)
* @author Administrator
*
*/
public class DateFunctionUtils {
private static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss";

View File

@ -8,8 +8,19 @@ import java.nio.charset.Charset;
import org.apache.commons.io.IOUtils;
/**
* 文件读写 工具类 防止NPE
* @author Administrator
*
*/
public class FileFunctionUtils {
/**
*
* @param path 文件路径/
* @param createDirectory 是否需要创建
* @return File 文件
*/
private static File getFile(String path,boolean createDirectory){
File f = new File(path);
if(createDirectory&&!f.getParentFile().exists()){

View File

@ -2,6 +2,11 @@ package org.spiderflow.core.freemarker.functions.utils;
import com.alibaba.fastjson.JSON;
/**
* Json和String互相转换 工具类 防止NPE
* @author Administrator
*
*/
public class JsonFunctionUtils {
public static Object parse(String jsonString){

View File

@ -1,14 +1,25 @@
package org.spiderflow.core.freemarker.functions.utils;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
/**
* List 工具类 防止NPE 添加了类似python的split()方法
* @author Administrator
*
*/
public class ListFunctionUtils {
public static int length(List<?> list){
return list != null ? list.size() : 0;
}
/**
*
* @param list 原List
* @param len 按多长进行分割
* @return List<List<?>> 分割后的数组
*/
public static List<List<?>> split(List<?> list,int len){
List<List<?>> result = new ArrayList<>();
if (list == null || list.size() == 0 || len < 1) {

View File

@ -2,6 +2,11 @@ package org.spiderflow.core.freemarker.functions.utils;
import org.apache.commons.lang3.RandomUtils;
/**
* 随机数/字符串 生成方法
* @author Administrator
*
*/
public class RandomFunctionUtils {
public static int randomInt(int min,int max){
@ -16,6 +21,12 @@ public class RandomFunctionUtils {
return RandomUtils.nextLong(min, max);
}
/**
*
* @param chars 字符个数
* @param length 字符范围
* @return String 随机字符串
*/
public static String string(String chars,int length){
if (chars != null) {
char[] newChars = new char[length];

View File

@ -6,6 +6,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
* String 工具类 防止NPE
* @author Administrator
*
*/
public class StringFunctionUtils {
public static String substring(String content, int beginIndex) {
@ -80,6 +85,10 @@ public class StringFunctionUtils {
}
}
/**
* 生成UUID
* @return String UUID
*/
public static String uuid() {
return UUID.randomUUID().toString().replace("-", "");
}

View File

@ -5,6 +5,11 @@ import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
/**
* url 按指定字符集进行编码/解码 默认字符集(UTF-8) 工具类 防止NPE
* @author Administrator
*
*/
public class UrlFunctionUtils {
public static String encode(String url){

View File

@ -11,6 +11,11 @@ import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;
/**
* 请求对象包装类
* @author Administrator
*
*/
public class HttpRequest {
private String url;

View File

@ -6,6 +6,11 @@ import org.jsoup.Connection.Response;
import com.alibaba.fastjson.JSON;
/**
* 响应对象包装类
* @author Administrator
*
*/
public class HttpResponse {
private Response response;