Commit d3824844 authored by 王业明's avatar 王业明
Browse files

Fix:组件注册,先读原文件第一行,然后根据编码再读一次具体内容

parent f37d9af2
package cn.com.bankit.ide.bap.python.parser;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.com.bankit.ide.bap.constants.IComponentConstants;
import cn.com.bankit.ide.bap.python.parser.module.PythonFile;
import cn.com.bankit.ide.bap.python.parser.module.PythonFunction;
import cn.com.bankit.ide.bap.python.parser.module.PythonParameter;
import cn.com.bankit.ide.bap.python.parser.module.PythonTransition;
public class PythonComponentParser implements PythonComponentConstants
{
private File file;
private PythonFile pythonFile;
private int lineCounter = 0; // 当前处理的行数
private int multiLineCommentCount = 0; // 多行注释出现的次数
private Map<String, String> funName = new HashMap<String, String>();
private void parseFileName()
{
String fileName = file.getName();
if (fileName.indexOf(".py") != -1)
{
pythonFile.setFileName(fileName.substring(0, fileName.indexOf(".py")));
}
else if (fileName.indexOf(".PY") != -1)
{
pythonFile.setFileName(fileName.substring(0, fileName.indexOf(".PY")));
}
}
public PythonFile getPythonFile()
{
return pythonFile;
}
/**
* 处理类头部的注释信息
*
* @param pyClassModel
* @param lineContent
*/
private void parseFileHeader(String line)
{
String title = line;
if (line.indexOf(":") != -1)
{
title = line.substring(0,line.indexOf(":")).trim();
}
String context = line.substring(line.indexOf(":") + 1).trim();
if (C_FILE_PACKAGE.equals(title.replace(" ", "")))
{
pythonFile.setPackageName(context);
}
else if (C_FILE_LEVEL.equals(title.replace(" ", "")))
{
for (int i = 0; i < C_FILE_LEVELS.length; i++)
{
if (context.equals(C_FILE_LEVELS[i].replace(" ", "")))
{
pythonFile.setComponetLevel(context);
break;
}
}
}
else if (C_FILE_DEPRECATED.equals(title.replace(" ", "")))
{
pythonFile.setDeprecated(true);
}
else if (C_FILE_VERSION.equals(title.replace(" ", "")))
{
pythonFile.setVersion(context);
}
else if (C_FILE_PRIORITY.equals(title.replace(" ", "")))
{
pythonFile.setPriority(context);
}
}
private boolean isStartFun(String line)
{
if (multiLineCommentCount % 2 == 1)
return false;
if (!line.startsWith(FUNCTION_DEF + " "))
return false;
return true;
}
private void parseFunction(String line, BufferedReader br) throws IOException
{
PythonFunction pyFunction = new PythonFunction();
if (parseFunctionDecleration(pyFunction, line))
{
if (parseFunctionBlock(pyFunction, br))
{
if (funName.containsKey(pyFunction.getComponetName()))
{
pyFunction.setSameNameFun(funName.get(pyFunction.getComponetName()));
}
else
{
pythonFile.getListFunction().add(pyFunction);
funName.put(pyFunction.getComponetName(), pyFunction.getFunctionName());
}
}
}
}
private boolean parseFunctionDecleration(PythonFunction pyFunction, String functionDecleration)
{
String functionSignification = functionDecleration.substring(FUNCTION_DEF.length()).trim();
String functionName = functionSignification.substring(0, functionSignification.indexOf("(")).trim();
//过滤
if (!functionName.matches("^((" + IComponentConstants.CMP_PREFIX_P + ")|(" + IComponentConstants.CMP_PREFIX_B
+ ")|(" + IComponentConstants.CMP_PREFIX_A + ")).*"))
return false;
String bracketStr = functionDecleration.substring(functionDecleration.indexOf("(") + 1).trim();
String paramStr = bracketStr.substring(0, bracketStr.indexOf(")")).trim();
if (!paramStr.equals(""))
{
String args[] = paramStr.split(",");
pyFunction.setDeclareParamNum(args.length);
for(String arg : args)
{
pyFunction.addArgs(arg);
}
}
pyFunction.setFunctionName(functionName);
pyFunction.setLineNum(lineCounter);
return true;
}
private boolean parseFunctionBlock(PythonFunction pyFunction, BufferedReader br) throws IOException
{
String line = null;
int functionCommentCount = 0; // 记录当前方法的注释数目信息
while ((line = br.readLine()) != null)
{
line = line.trim();
lineCounter++;
// 读到多行注释,则记录总的注释数信息 并记录当前方法的注释数信息
if (line.equals(MULTI_LINE_COMMENT))
{
multiLineCommentCount++;
if (functionCommentCount++ == 1)
break;
else
continue;
}
else if (functionCommentCount == 0 && line.trim().length() != 0)
{
//没有注释注释返回
return false;
}
// 如果当前方法的注释数为1,则认为处在当前方法的注释信息内 处理当前方法的注释
if (functionCommentCount == 1)
{
parseFunctionComment(pyFunction, line);
}
}
return true;
}
int I_NONE = 0x0000;
int I_C_FUNCTION_NAME = 0x0001;
int I_C_FUNCTION_DESC = 0x0002;
int I_C_FUNCTION_IN_ARGS = 0x0003;
int I_C_FUNCTION_OUT_ARGS = 0x0004;
int I_C_FUNCTION_TRANSITIONS = 0x0005;
int I_C_FUNCTION_RETURN = 0x0006;
int I_C_FUNCTION_DEPRECATED = 0x0007;
int I_C_FUNCTION_PRIORITY = 0x0008;
int I_C_FUNCTION_VERSION = 0x0009;
int I_C_FUNCTION_USECASE = 0x000A;
int I_C_FUNCTION_PARAM = 0x000B;
int I_ARG_INIT = 0x00;
int I_ARG_IN = 0x01;
int I_ARG_OUT = 0x02;
int markFlag = 0;
int isInArgs = I_ARG_INIT;
boolean isReturnVal = false;
private boolean containRegKey(String line,String key)
{
// if (line.indexOf(key) != -1 )
// return true;
if (line.trim().startsWith(key))
return true;
return false;
}
private void parseFunctionComment(PythonFunction function, String line)
{
int curMarkFlag = I_NONE;
if (containRegKey(line,C_FUNCTION_NAME))
{
curMarkFlag = I_C_FUNCTION_NAME;
}
else if (containRegKey(line,C_FUNCTION_DESC))
{
curMarkFlag = I_C_FUNCTION_DESC;
}
else if (containRegKey(line,C_FUNCTION_IN_ARGS))
{
isInArgs = I_ARG_IN;
return;
}
else if (containRegKey(line,C_FUNCTION_OUT_ARGS))
{
isInArgs = I_ARG_OUT;
return;
}
else if (containRegKey(line,C_FUNCTION_PARAM) && I_ARG_INIT != isInArgs)
{
curMarkFlag = I_C_FUNCTION_PARAM;
}
else if (containRegKey(line,C_FUNCTION_TRANSITIONS))
{
isReturnVal = true;
return;
}
else if ( containRegKey(line,C_FUNCTION_RETURN) && isReturnVal)
{
curMarkFlag = I_C_FUNCTION_RETURN;
}
else if ( containRegKey(line,C_FUNCTION_DEPRECATED))
{
curMarkFlag = I_C_FUNCTION_DEPRECATED;
}
else if ( containRegKey(line,C_FUNCTION_PRIORITY))
{
curMarkFlag = I_C_FUNCTION_PRIORITY;
}
else if ( containRegKey(line,C_FUNCTION_VERSION))
{
curMarkFlag = I_C_FUNCTION_VERSION;
}
else if ( containRegKey(line,C_FUNCTION_USECASE))
{
curMarkFlag = I_C_FUNCTION_USECASE;
}
else
{
//用户自定义的注释,不进行解析。
if(line.trim().startsWith("@") && I_C_FUNCTION_USECASE != markFlag)
{
markFlag = I_NONE;
return;
}
}
if (I_NONE == markFlag || I_NONE != curMarkFlag)
{
markFlag = curMarkFlag;
}
if(I_NONE != markFlag)
{
setValues(function,line,curMarkFlag);
}
}
private void getAndSet(PythonFunction function,String attr, String val, int flag)
{
try
{
if(null == function || null == attr || null == val)
return;
String strVal = val;
Field field = function.getClass().getDeclaredField(attr);
field.setAccessible(true);
if(I_NONE == flag)
{
Object value = field.get(function);
if(null != value)
{
strVal = String.valueOf(value) + "\n" + strVal;
}
}
field.set(function, strVal);
} catch (Exception e)
{
e.printStackTrace();
}
}
/**
*
* @param function
* @param line
* @param flag 如果为0,说明是换行。
*/
private void setValues(PythonFunction function, String line, int flag)
{
String context = line;
if(I_NONE != flag)
{
if (line.indexOf(":") != -1)
{
context = line.substring(line.indexOf(":") + 1).trim();
}
else
{
context = line.substring(line.indexOf(":") + 1).trim();
}
}
if (I_C_FUNCTION_NAME == markFlag)
{
function.setComponetName(context);
}
else if (I_C_FUNCTION_DESC == markFlag)
{
getAndSet(function,"componetDesc",context,flag);
}
else if (I_C_FUNCTION_PARAM == markFlag)
{
if (I_ARG_IN == isInArgs)// 入参
{
function.getInArgList().add(parserParam(line));
}
if (I_ARG_OUT == isInArgs)// 出参
{
function.getOutArgList().add(parserParam(line));
}
}
else if ( I_C_FUNCTION_RETURN == markFlag && isReturnVal)
{
function.getReturnType().add(parserReturn(line));
}
else if ( I_C_FUNCTION_DEPRECATED == markFlag)
{
function.setDeprecated(true);
}
else if (I_C_FUNCTION_PRIORITY == markFlag)
{
function.setPriority(context);
}
else if ( I_C_FUNCTION_VERSION == markFlag)
{
function.setVersion(context);
}
else if ( I_C_FUNCTION_USECASE == markFlag )
{
getAndSet(function,"useCase",context,flag);
}
}
private PythonParameter parserParam(String line)
{
PythonParameter parameter = new PythonParameter();
String[] strArr = splitBySpace(line, 4);
String name = strArr[1];
String type = strArr[2];
String desc = strArr[3];
parameter.setName(name);
parameter.setType(type);
parameter.setDesc(desc);
return parameter;
}
private PythonTransition parserReturn(String line)
{
PythonTransition trans = new PythonTransition();
String[] strArr = splitBySpace(line, 3);
String name = strArr[1];
String desc = strArr[2];
trans.setName(name);
trans.setDesc(desc);
return trans;
}
public PythonFile parse(File file, String charsetName) throws PythonParseExcption
{
this.file = file;
BufferedReader br = null;
try
{
br = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
pythonFile = new PythonFile();
parseFileName();
String line = null;
while ((line = br.readLine()) != null)
{
line = line.trim();
lineCounter++;
// 出现多行注释标志,就记录下多行注释数,不做处理
if (line.equals(MULTI_LINE_COMMENT))
{
multiLineCommentCount++;
continue;
}
// 第一次出现多行注释,就作为文件注释
if (multiLineCommentCount == 1)
{
parseFileHeader(line);
// if (1 == res)
// {
// return pythonFile;
// }
}
// 不在多行注释内,且读到一个function标志,则处理function
else if (isStartFun(line))
{
parseFunction(line, br);
}
}
// 处理过时函数
// pyCompileUnit.handleDeprecatedFunction();
List<String> list = pythonFile.check();
if (list.size() > 0)
{
throw new PythonParseExcption(list);
}
return pythonFile;
}
catch (IOException e)
{
throw new PythonParseExcption(e);
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
private String[] splitBySpace(String source, int size)
{
String[] words = new String[size];
for (int i = 0; i < size; i++)
{
int indexOf = source.indexOf(" ");
if (indexOf != -1)
{
words[i] = source.substring(0, indexOf);
source = source.substring(indexOf).trim();
}
else
{
words[i] = source.trim();
}
}
return words;
}
}
package cn.com.bankit.ide.bap.python.parser;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.com.bankit.ide.bap.constants.IComponentConstants;
import cn.com.bankit.ide.bap.python.parser.module.PythonFile;
import cn.com.bankit.ide.bap.python.parser.module.PythonFunction;
import cn.com.bankit.ide.bap.python.parser.module.PythonParameter;
import cn.com.bankit.ide.bap.python.parser.module.PythonTransition;
public class PythonComponentParser implements PythonComponentConstants
{
private File file;
private PythonFile pythonFile;
private int lineCounter = 0; // 当前处理的行数
private int multiLineCommentCount = 0; // 多行注释出现的次数
private Map<String, String> funName = new HashMap<String, String>();
private void parseFileName()
{
String fileName = file.getName();
if (fileName.indexOf(".py") != -1)
{
pythonFile.setFileName(fileName.substring(0, fileName.indexOf(".py")));
}
else if (fileName.indexOf(".PY") != -1)
{
pythonFile.setFileName(fileName.substring(0, fileName.indexOf(".PY")));
}
}
public PythonFile getPythonFile()
{
return pythonFile;
}
/**
* 处理类头部的注释信息
*
* @param pyClassModel
* @param lineContent
*/
private void parseFileHeader(String line)
{
String title = line;
if (line.indexOf(":") != -1)
{
title = line.substring(0,line.indexOf(":")).trim();
}
String context = line.substring(line.indexOf(":") + 1).trim();
if (C_FILE_PACKAGE.equals(title.replace(" ", "")))
{
pythonFile.setPackageName(context);
}
else if (C_FILE_LEVEL.equals(title.replace(" ", "")))
{
for (int i = 0; i < C_FILE_LEVELS.length; i++)
{
if (context.equals(C_FILE_LEVELS[i].replace(" ", "")))
{
pythonFile.setComponetLevel(context);
break;
}
}
}
else if (C_FILE_DEPRECATED.equals(title.replace(" ", "")))
{
pythonFile.setDeprecated(true);
}
else if (C_FILE_VERSION.equals(title.replace(" ", "")))
{
pythonFile.setVersion(context);
}
else if (C_FILE_PRIORITY.equals(title.replace(" ", "")))
{
pythonFile.setPriority(context);
}
}
private boolean isStartFun(String line)
{
if (multiLineCommentCount % 2 == 1)
return false;
if (!line.startsWith(FUNCTION_DEF + " "))
return false;
return true;
}
private void parseFunction(String line, BufferedReader br) throws IOException
{
PythonFunction pyFunction = new PythonFunction();
if (parseFunctionDecleration(pyFunction, line))
{
if (parseFunctionBlock(pyFunction, br))
{
if (funName.containsKey(pyFunction.getComponetName()))
{
pyFunction.setSameNameFun(funName.get(pyFunction.getComponetName()));
}
else
{
pythonFile.getListFunction().add(pyFunction);
funName.put(pyFunction.getComponetName(), pyFunction.getFunctionName());
}
}
}
}
private boolean parseFunctionDecleration(PythonFunction pyFunction, String functionDecleration)
{
String functionSignification = functionDecleration.substring(FUNCTION_DEF.length()).trim();
String functionName = functionSignification.substring(0, functionSignification.indexOf("(")).trim();
//过滤
if (!functionName.matches("^((" + IComponentConstants.CMP_PREFIX_P + ")|(" + IComponentConstants.CMP_PREFIX_B
+ ")|(" + IComponentConstants.CMP_PREFIX_A + ")).*"))
return false;
String bracketStr = functionDecleration.substring(functionDecleration.indexOf("(") + 1).trim();
String paramStr = bracketStr.substring(0, bracketStr.indexOf(")")).trim();
if (!paramStr.equals(""))
{
String args[] = paramStr.split(",");
pyFunction.setDeclareParamNum(args.length);
for(String arg : args)
{
pyFunction.addArgs(arg);
}
}
pyFunction.setFunctionName(functionName);
pyFunction.setLineNum(lineCounter);
return true;
}
private boolean parseFunctionBlock(PythonFunction pyFunction, BufferedReader br) throws IOException
{
String line = null;
int functionCommentCount = 0; // 记录当前方法的注释数目信息
while ((line = br.readLine()) != null)
{
line = line.trim();
lineCounter++;
// 读到多行注释,则记录总的注释数信息 并记录当前方法的注释数信息
if (line.equals(MULTI_LINE_COMMENT))
{
multiLineCommentCount++;
if (functionCommentCount++ == 1)
break;
else
continue;
}
else if (functionCommentCount == 0 && line.trim().length() != 0)
{
//没有注释注释返回
return false;
}
// 如果当前方法的注释数为1,则认为处在当前方法的注释信息内 处理当前方法的注释
if (functionCommentCount == 1)
{
parseFunctionComment(pyFunction, line);
}
}
return true;
}
int I_NONE = 0x0000;
int I_C_FUNCTION_NAME = 0x0001;
int I_C_FUNCTION_DESC = 0x0002;
int I_C_FUNCTION_IN_ARGS = 0x0003;
int I_C_FUNCTION_OUT_ARGS = 0x0004;
int I_C_FUNCTION_TRANSITIONS = 0x0005;
int I_C_FUNCTION_RETURN = 0x0006;
int I_C_FUNCTION_DEPRECATED = 0x0007;
int I_C_FUNCTION_PRIORITY = 0x0008;
int I_C_FUNCTION_VERSION = 0x0009;
int I_C_FUNCTION_USECASE = 0x000A;
int I_C_FUNCTION_PARAM = 0x000B;
int I_ARG_INIT = 0x00;
int I_ARG_IN = 0x01;
int I_ARG_OUT = 0x02;
int markFlag = 0;
int isInArgs = I_ARG_INIT;
boolean isReturnVal = false;
private boolean containRegKey(String line,String key)
{
// if (line.indexOf(key) != -1 )
// return true;
if (line.trim().startsWith(key))
return true;
return false;
}
private void parseFunctionComment(PythonFunction function, String line)
{
int curMarkFlag = I_NONE;
if (containRegKey(line,C_FUNCTION_NAME))
{
curMarkFlag = I_C_FUNCTION_NAME;
}
else if (containRegKey(line,C_FUNCTION_DESC))
{
curMarkFlag = I_C_FUNCTION_DESC;
}
else if (containRegKey(line,C_FUNCTION_IN_ARGS))
{
isInArgs = I_ARG_IN;
return;
}
else if (containRegKey(line,C_FUNCTION_OUT_ARGS))
{
isInArgs = I_ARG_OUT;
return;
}
else if (containRegKey(line,C_FUNCTION_PARAM) && I_ARG_INIT != isInArgs)
{
curMarkFlag = I_C_FUNCTION_PARAM;
}
else if (containRegKey(line,C_FUNCTION_TRANSITIONS))
{
isReturnVal = true;
return;
}
else if ( containRegKey(line,C_FUNCTION_RETURN) && isReturnVal)
{
curMarkFlag = I_C_FUNCTION_RETURN;
}
else if ( containRegKey(line,C_FUNCTION_DEPRECATED))
{
curMarkFlag = I_C_FUNCTION_DEPRECATED;
}
else if ( containRegKey(line,C_FUNCTION_PRIORITY))
{
curMarkFlag = I_C_FUNCTION_PRIORITY;
}
else if ( containRegKey(line,C_FUNCTION_VERSION))
{
curMarkFlag = I_C_FUNCTION_VERSION;
}
else if ( containRegKey(line,C_FUNCTION_USECASE))
{
curMarkFlag = I_C_FUNCTION_USECASE;
}
else
{
//用户自定义的注释,不进行解析。
if(line.trim().startsWith("@") && I_C_FUNCTION_USECASE != markFlag)
{
markFlag = I_NONE;
return;
}
}
if (I_NONE == markFlag || I_NONE != curMarkFlag)
{
markFlag = curMarkFlag;
}
if(I_NONE != markFlag)
{
setValues(function,line,curMarkFlag);
}
}
private void getAndSet(PythonFunction function,String attr, String val, int flag)
{
try
{
if(null == function || null == attr || null == val)
return;
String strVal = val;
Field field = function.getClass().getDeclaredField(attr);
field.setAccessible(true);
if(I_NONE == flag)
{
Object value = field.get(function);
if(null != value)
{
strVal = String.valueOf(value) + "\n" + strVal;
}
}
field.set(function, strVal);
} catch (Exception e)
{
e.printStackTrace();
}
}
/**
*
* @param function
* @param line
* @param flag 如果为0,说明是换行。
*/
private void setValues(PythonFunction function, String line, int flag)
{
String context = line;
if(I_NONE != flag)
{
if (line.indexOf(":") != -1)
{
context = line.substring(line.indexOf(":") + 1).trim();
}
else
{
context = line.substring(line.indexOf(":") + 1).trim();
}
}
if (I_C_FUNCTION_NAME == markFlag)
{
function.setComponetName(context);
}
else if (I_C_FUNCTION_DESC == markFlag)
{
getAndSet(function,"componetDesc",context,flag);
}
else if (I_C_FUNCTION_PARAM == markFlag)
{
if (I_ARG_IN == isInArgs)// 入参
{
function.getInArgList().add(parserParam(line));
}
if (I_ARG_OUT == isInArgs)// 出参
{
function.getOutArgList().add(parserParam(line));
}
}
else if ( I_C_FUNCTION_RETURN == markFlag && isReturnVal)
{
function.getReturnType().add(parserReturn(line));
}
else if ( I_C_FUNCTION_DEPRECATED == markFlag)
{
function.setDeprecated(true);
}
else if (I_C_FUNCTION_PRIORITY == markFlag)
{
function.setPriority(context);
}
else if ( I_C_FUNCTION_VERSION == markFlag)
{
function.setVersion(context);
}
else if ( I_C_FUNCTION_USECASE == markFlag )
{
getAndSet(function,"useCase",context,flag);
}
}
private PythonParameter parserParam(String line)
{
PythonParameter parameter = new PythonParameter();
String[] strArr = splitBySpace(line, 4);
String name = strArr[1];
String type = strArr[2];
String desc = strArr[3];
parameter.setName(name);
parameter.setType(type);
parameter.setDesc(desc);
return parameter;
}
private PythonTransition parserReturn(String line)
{
PythonTransition trans = new PythonTransition();
String[] strArr = splitBySpace(line, 3);
String name = strArr[1];
String desc = strArr[2];
trans.setName(name);
trans.setDesc(desc);
return trans;
}
public PythonFile parse(File file, String charsetName) throws PythonParseExcption
{
this.file = file;
BufferedReader br = null;
charsetName = getCharsetName(file, charsetName);
try
{
br = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
pythonFile = new PythonFile();
parseFileName();
String line = null;
while ((line = br.readLine()) != null)
{
line = line.trim();
lineCounter++;
// 出现多行注释标志,就记录下多行注释数,不做处理
if (line.equals(MULTI_LINE_COMMENT))
{
multiLineCommentCount++;
continue;
}
// 第一次出现多行注释,就作为文件注释
if (multiLineCommentCount == 1)
{
parseFileHeader(line);
// if (1 == res)
// {
// return pythonFile;
// }
}
// 不在多行注释内,且读到一个function标志,则处理function
else if (isStartFun(line))
{
parseFunction(line, br);
}
}
// 处理过时函数
// pyCompileUnit.handleDeprecatedFunction();
List<String> list = pythonFile.check();
if (list.size() > 0)
{
throw new PythonParseExcption(list);
}
return pythonFile;
}
catch (IOException e)
{
throw new PythonParseExcption(e);
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
private String[] splitBySpace(String source, int size)
{
String[] words = new String[size];
for (int i = 0; i < size; i++)
{
int indexOf = source.indexOf(" ");
if (indexOf != -1)
{
words[i] = source.substring(0, indexOf);
source = source.substring(indexOf).trim();
}
else
{
words[i] = source.trim();
}
}
return words;
}
public String getCharsetName(File file, String charsetName) throws PythonParseExcption
{
BufferedReader br = null;
try
{
br = new BufferedReader(new InputStreamReader(new FileInputStream(file), charsetName));
String line = br.readLine();
int index = -1;
if (line != null) {
if ((index = line.indexOf("# -*- coding:")) > -1) {
int lastIdx = line.lastIndexOf("-*-");
if (lastIdx > -1) {
charsetName = line.substring(index + 13, lastIdx).trim();
} else {
charsetName = line.substring(index + 13).trim();
}
}
}
return charsetName;
}
catch (IOException e)
{
throw new PythonParseExcption(e);
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment