Search in sources :

Example 1 with ProgramSpecSourceException

use of com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException 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 ProgramSpecSourceException

use of com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException 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 ProgramSpecSourceException

use of com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException in project Gargoyle by callakrsos.

the class ProgramSpecUtil method doJavaFile.

public static ProgramSpecSVO doJavaFile(String projectName, String fileName, AbstractJavaProgramSpecFile newInstance) {
    ProgramSpecSVO svo = new ProgramSpecSVO();
    String packageNames = newInstance.getPackage();
    newInstance.setPackage(packageNames);
    newInstance.setProjectName(projectName);
    svo.setFile(newInstance);
    // svo.getUserSourceMetaDVO().setProjectName(projectName);
    // svo.getUserSourceMetaDVO().setPackages(packageNames);
    String userName = System.getProperty("user.name");
    List<SourceAnalysisDVO> listStatement = newInstance.listStatement();
    UserSourceMetaDVO userSourceMetaDVO = new UserSourceMetaDVO();
    userSourceMetaDVO.setProjectName(projectName);
    userSourceMetaDVO.setSimpleFileName(fileName);
    userSourceMetaDVO.setRealFilePath(newInstance.getFullFileName());
    userSourceMetaDVO.setUserPcName(userName);
    userSourceMetaDVO.setPackages(packageNames);
    svo.setUserSourceMetaDVO(userSourceMetaDVO);
    /* 시작 import문 처리 */
    List<String> imports = newInstance.getImports();
    ImportsDVO importsDVO = new ImportsDVO();
    importsDVO.setImports(imports);
    svo.setImportsDVO(importsDVO);
    /* 끝 import문 처리 */
    // 테이블 데이터 바인드
    List<MethodDVO> methodDVOList = new ArrayList<MethodDVO>();
    for (SourceAnalysisDVO dvo : listStatement) {
        try {
            // 소스내에 존재하는 메소드명.. 접근지 정자 + static + void 등의 잡다한 정보가 담겨있다.
            String methodName = dvo.getMethodName();
            String methodDescription = newInstance.getMethodDescription(methodName);
            MethodDVO methodDVO = null;
            methodDVO = AbstractJavaProgramSpecFile.toMethodDVO(methodName);
            methodDVO.setDescription(methodDescription);
            methodDVOList.add(methodDVO);
        } catch (ProgramSpecSourceException e) {
            e.printStackTrace();
        }
    }
    svo.setMethodDVOList(methodDVOList);
    return svo;
}
Also used : ImportsDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ImportsDVO) UserSourceMetaDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.UserSourceMetaDVO) ArrayList(java.util.ArrayList) ProgramSpecSVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ProgramSpecSVO) ProgramSpecSourceException(com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException) MethodDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodDVO) SourceAnalysisDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO)

Example 4 with ProgramSpecSourceException

use of com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException in project Gargoyle by callakrsos.

the class ProgramSpecUtil method doJsFile.

public static ProgramSpecSVO doJsFile(String projectName, String fileName, AbstractXframeProgramSpecFile newInstance) {
    ProgramSpecSVO svo = new ProgramSpecSVO();
    newInstance.setProjectName(projectName);
    svo.setFile(newInstance);
    String userName = System.getProperty("user.name");
    List<SourceAnalysisDVO> listStatement = newInstance.listStatement();
    UserSourceMetaDVO userSourceMetaDVO = new UserSourceMetaDVO();
    userSourceMetaDVO.setProjectName(projectName);
    userSourceMetaDVO.setSimpleFileName(fileName);
    userSourceMetaDVO.setRealFilePath(newInstance.getFullFileName());
    userSourceMetaDVO.setUserPcName(userName);
    userSourceMetaDVO.setPackages("");
    svo.setUserSourceMetaDVO(userSourceMetaDVO);
    /* 시작 import문 처리 */
    svo.setImportsDVO(new ImportsDVO());
    /* 끝 import문 처리 */
    // 테이블 데이터 바인드
    List<MethodDVO> methodDVOList = new ArrayList<MethodDVO>();
    for (SourceAnalysisDVO dvo : listStatement) {
        try {
            // 소스내에 존재하는 메소드명.. 접근지 정자 + static + void 등의 잡다한 정보가 담겨있다.
            String methodName = dvo.getMethodName();
            String methodDescription = newInstance.getMethodDescription(methodName);
            MethodDVO methodDVO = null;
            methodDVO = AbstractXframeProgramSpecFile.toMethodDVO(methodName);
            methodDVO.setDescription(methodDescription);
            methodDVOList.add(methodDVO);
        } catch (ProgramSpecSourceException e) {
            e.printStackTrace();
        }
    }
    svo.setMethodDVOList(methodDVOList);
    return svo;
}
Also used : ImportsDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ImportsDVO) UserSourceMetaDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.UserSourceMetaDVO) ArrayList(java.util.ArrayList) ProgramSpecSVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ProgramSpecSVO) ProgramSpecSourceException(com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException) MethodDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodDVO) SourceAnalysisDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO)

Aggregations

ProgramSpecSourceException (com.kyj.fx.voeditor.visual.exceptions.ProgramSpecSourceException)4 MethodDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodDVO)4 ImportsDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ImportsDVO)2 MethodParameterDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.MethodParameterDVO)2 ProgramSpecSVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.ProgramSpecSVO)2 SourceAnalysisDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO)2 UserSourceMetaDVO (com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.UserSourceMetaDVO)2 ArrayList (java.util.ArrayList)2