Search in sources :

Example 1 with MethodParameterDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO in project Gargoyle by callakrsos.

the class AbstractXframeProgramSpecFile method toMethodDVO.

public static MethodDVO toMethodDVO(String fullMethodName) throws ProgramSpecSourceException {
    String tempName = fullMethodName;
    MethodDVO methodDVO = new MethodDVO();
    methodDVO.setLevel("");
    // 파라미터부분 반환
    String parameterMatched = ValueUtil.regexMatch("\\([\\w\\W]{0,}\\)", tempName).trim();
    if (ValueUtil.isEmpty(parameterMatched)) {
        throw new ProgramSpecSourceException("[버그]파라미터 블록 확인바람.");
    }
    // 파라미터값 추출.
    int startParam_indexOf = parameterMatched.indexOf("(");
    int endParam_indexOf = parameterMatched.indexOf(")");
    String parameterContent = parameterMatched.substring(startParam_indexOf + 1, endParam_indexOf);
    System.out.println(parameterContent);
    List<MethodParameterDVO> convertParameterDVO = convertParameterDVO(parameterContent);
    System.out.println(convertParameterDVO);
    // Simple MethodName 추출.
    int indexOf = tempName.indexOf(parameterMatched);
    // [시작] 2015.3.5 파라미터에 [] 문자가 존재할 경우 정규식으로 인식하는 문제때문에 교체.
    // tempName = tempName.replaceAll(parameterMatched, "").trim();
    tempName = tempName.substring(0, indexOf).trim();
    // [끝] 2015.3.5 파라미터에 [] 문자가 존재할 경우 정규식으로 인식하는 문제때문에 교체.
    String[] args = tempName.split("\\s+");
    String simpleMethodName = args[args.length - 1];
    // 리턴타입 추출.
    String returnType = "";
    for (int i = 0; i < args.length - 1; i++) {
        returnType += args[i] + " ";
    }
    if (returnType.isEmpty()) {
        returnType = "void";
    }
    methodDVO.setReturnType(returnType);
    methodDVO.setMethodName(simpleMethodName);
    methodDVO.setMethodParameterDVOList(convertParameterDVO);
    return methodDVO;
}
Also used : MethodParameterDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO) ProgramSpecSourceException(com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException) MethodDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodDVO)

Example 2 with MethodParameterDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO in project Gargoyle by callakrsos.

the class AbstractJavaProgramSpecFile method toMethodDVO.

/**
	 * 타입 + {static} + 메소드명 +( 파라미터 ) 형식을 을 갖는 메소드 문자열로부터 정규화된 MethodDVO를 반환받는다.
	 *
	 * @param fullMethodName
	 * @return
	 * @throws ProgramSpecSourceException
	 */
public static MethodDVO toMethodDVO(final String fullMethodName) throws ProgramSpecSourceException {
    String tempName = fullMethodName;
    MethodDVO methodDVO = new MethodDVO();
    // 접근지정자 추출.
    String accessModifiers = "";
    if (tempName.startsWith("public")) {
        accessModifiers = "public";
        tempName = tempName.substring(tempName.indexOf(accessModifiers) + accessModifiers.length(), tempName.length()).trim();
    } else if (tempName.startsWith("private")) {
        accessModifiers = "private";
        tempName = tempName.substring(tempName.indexOf(accessModifiers) + accessModifiers.length(), tempName.length()).trim();
    } else if (tempName.startsWith("protected")) {
        accessModifiers = "protected";
        tempName = tempName.substring(tempName.indexOf(accessModifiers) + accessModifiers.length(), tempName.length()).trim();
    } else if (tempName.startsWith("default")) {
        accessModifiers = "default";
        tempName = tempName.substring(tempName.indexOf(accessModifiers) + accessModifiers.length(), tempName.length()).trim();
    } else {
        accessModifiers = "default";
    }
    // 접근지정자 저장.
    methodDVO.setVisivility(accessModifiers);
    // static 존재유무 확인. static의 존재유무에 따라 instance인지 static인지 구분.
    int static_indexOf = tempName.indexOf("static ");
    if (static_indexOf != -1) {
        tempName = tempName.substring(static_indexOf + "static ".length(), tempName.length()).trim();
        methodDVO.setLevel("Static \nMethod");
    } else {
        methodDVO.setLevel("Instance \nMethod");
    }
    // 예외처리 존재하면 지움.
    int throw_indexOf = tempName.indexOf(" throws ");
    if (throw_indexOf != -1) {
        tempName = tempName.substring(0, throw_indexOf).trim();
    }
    // 파라미터부분 반환
    String parameterMatched = ValueUtil.regexMatch("\\([\\w\\W]{0,}\\)", tempName).trim();
    if (ValueUtil.isEmpty(parameterMatched)) {
        throw new ProgramSpecSourceException("[버그]파라미터 블록 확인바람.");
    }
    // 파라미터값 추출.
    int startParam_indexOf = parameterMatched.indexOf("(");
    int endParam_indexOf = parameterMatched.indexOf(")");
    String parameterContent = parameterMatched.substring(startParam_indexOf + 1, endParam_indexOf);
    System.out.println(parameterContent);
    List<MethodParameterDVO> convertParameterDVO = convertParameterDVO(parameterContent);
    System.out.println(convertParameterDVO);
    // Simple MethodName 추출.
    int indexOf = tempName.indexOf(parameterMatched);
    // [시작] 2015.3.5 파라미터에 [] 문자가 존재할 경우 정규식으로 인식하는 문제때문에 교체.
    // tempName = tempName.replaceAll(parameterMatched, "").trim();
    tempName = tempName.substring(0, indexOf).trim();
    // [끝] 2015.3.5 파라미터에 [] 문자가 존재할 경우 정규식으로 인식하는 문제때문에 교체.
    String[] args = tempName.split("\\s+");
    String simpleMethodName = args[args.length - 1];
    // 리턴타입 추출.
    String returnType = "";
    for (int i = 0; i < args.length - 1; i++) {
        returnType += args[i] + " ";
    }
    if (returnType.isEmpty()) {
        returnType = "void";
    }
    methodDVO.setReturnType(returnType);
    methodDVO.setMethodName(simpleMethodName);
    methodDVO.setMethodParameterDVOList(convertParameterDVO);
    return methodDVO;
}
Also used : MethodParameterDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO) ProgramSpecSourceException(com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException) MethodDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodDVO)

Example 3 with MethodParameterDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO in project Gargoyle by callakrsos.

the class AbstractJavaProgramSpecFile method convertGenericParameterDVO.

/**
	 * 제네릭 파라미터를 갖는 데이터형으로부터 정규화된 MethodParameterDVO로 반환받는다.
	 *
	 * @param data
	 * @return
	 */
private static MethodParameterDVO convertGenericParameterDVO(String data) {
    String[] split = data.trim().split("\\s+");
    String type = "";
    if (split.length > 2) {
        type = ValueUtil.valueOf(split, 0, split.length - 2);
    } else {
        type = split[0];
    }
    MethodParameterDVO methodParameterDVO = new MethodParameterDVO(split[split.length - 1], type, type, type);
    return methodParameterDVO;
}
Also used : MethodParameterDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO)

Example 4 with MethodParameterDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO in project Gargoyle by callakrsos.

the class AbstractJavaProgramSpecFile method convertParameterDVO.

/**
	 * 파라미터 스트링으로부터 정규화된 데이터셋으로 변환한다.
	 *
	 * @param parameterString
	 * @return
	 */
static List<MethodParameterDVO> convertParameterDVO(String parameterString) {
    List<MethodParameterDVO> rsltList = new ArrayList<MethodParameterDVO>();
    // 빈 문자열이면 빈값 반환
    if (ValueUtil.isEmpty(parameterString)) {
        return rsltList;
    }
    String tempPram = parameterString;
    // 없다면 간단히 문자열을 나누고 찾음.
    if (tempPram.indexOf(PARAMETER_GENERIC_TYPE) != -1) {
        for (String parameterm : tempPram.split(",")) {
            String[] split = parameterm.split("\\s+");
            MethodParameterDVO methodParameterDVO = new MethodParameterDVO(split[1], split[0], split[0], split[0]);
            rsltList.add(methodParameterDVO);
            System.out.println(parameterm.trim());
        }
    } else // 제네릭타입이 존재한다면 ..
    {
        // 1. 일시적으로 제네릭 타입은 제거함.
        // tempPram = tempPram.replaceAll(PARAMETER_GENERIC_TYPE, "");
        StringBuffer tempBuffer = new StringBuffer();
        int startCnt = 0;
        int endCnt = 0;
        // 2. 제네릭 타입을 제거한후 세미콜론으로 문자열을 나누면 파라미터의 갯수를 추측할 수 있다.
        for (String parameterm : tempPram.split(",")) {
            String trim = parameterm.trim();
            List<String> regexSMatchs = ValueUtil.regexMatchs("<", trim);
            List<String> regexEMatchs = ValueUtil.regexMatchs(">", trim);
            if (regexSMatchs.size() == 0 && regexEMatchs.size() == 0) {
                MethodParameterDVO methodParameterDVO = null;
                // /파라미터 타입이 ... 인경우 []로 변환함
                String[] dotSplit = trim.trim().split("\\.\\.\\.");
                if (dotSplit.length > 1) {
                    String type = ValueUtil.valueOf(dotSplit, 0, dotSplit.length - 1).trim() + "[]";
                    methodParameterDVO = new MethodParameterDVO(dotSplit[dotSplit.length - 1].trim(), type, type, type);
                } else {
                    String[] split = trim.trim().split("\\s+");
                    methodParameterDVO = new MethodParameterDVO(split[1].trim(), split[0], split[0], split[0]);
                }
                rsltList.add(methodParameterDVO);
                System.out.println(methodParameterDVO.getParameterType() + " : " + methodParameterDVO.getParameter());
            } else if (regexSMatchs.size() > 0 && regexEMatchs.size() > 0) {
                startCnt += regexSMatchs.size();
                endCnt += regexEMatchs.size();
                tempBuffer.append(trim.trim());
                if (startCnt == endCnt) {
                    startCnt = 0;
                    endCnt = 0;
                    MethodParameterDVO methodParameterDVO = convertGenericParameterDVO(tempBuffer.toString());
                    rsltList.add(methodParameterDVO);
                    System.out.println(methodParameterDVO.getParameterType() + " : " + methodParameterDVO.getParameter());
                    tempBuffer.setLength(0);
                }
            } else if (regexSMatchs.size() > 0 && regexEMatchs.size() == 0) {
                startCnt += regexSMatchs.size();
                tempBuffer.append(trim.trim()).append(",");
            } else if (regexSMatchs.size() == 0 && regexEMatchs.size() > 0) {
                endCnt += regexEMatchs.size();
                tempBuffer.append(trim.trim());
                if (startCnt == endCnt) {
                    startCnt = 0;
                    endCnt = 0;
                    MethodParameterDVO methodParameterDVO = convertGenericParameterDVO(tempBuffer.toString());
                    System.out.println(methodParameterDVO.getParameterType() + " : " + methodParameterDVO.getParameter());
                    rsltList.add(methodParameterDVO);
                    tempBuffer.setLength(0);
                }
            }
        }
    }
    return rsltList;
}
Also used : MethodParameterDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO) ArrayList(java.util.ArrayList)

Example 5 with MethodParameterDVO

use of com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO in project Gargoyle by callakrsos.

the class AbstractXframeProgramSpecFile method convertParameterDVO.

/**
	 * 파라미터 스트링으로부터 정규화된 데이터셋으로 변환한다.
	 *
	 * @param parameterString
	 * @return
	 */
static List<MethodParameterDVO> convertParameterDVO(String parameterString) {
    List<MethodParameterDVO> rsltList = new ArrayList<MethodParameterDVO>();
    // 빈 문자열이면 빈값 반환
    if (ValueUtil.isEmpty(parameterString)) {
        return rsltList;
    }
    String tempPram = parameterString;
    for (String parameterm : tempPram.split(",")) {
        MethodParameterDVO methodParameterDVO = new MethodParameterDVO(parameterm.trim(), "var", "var", "var");
        rsltList.add(methodParameterDVO);
        System.out.println(parameterm.trim());
    }
    return rsltList;
}
Also used : MethodParameterDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO) ArrayList(java.util.ArrayList)

Aggregations

MethodParameterDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO)6 ArrayList (java.util.ArrayList)3 ProgramSpecSourceException (com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException)2 MethodDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodDVO)2 List (java.util.List)1 XWPFTable (org.apache.poi.xwpf.usermodel.XWPFTable)1