/*************** 轉換function ***************/
// Java to JavaScript
public static String convertToJavaScriptValue(String str)
throws IOException
{
if ((str != null) && (!"".equals(str)))
{
str = replaceChar(str, '\n', "\\n");
str = replaceChar(str, '\r', "");
str = replaceChar(str, '\'', "'");
str = replaceChar(str, '"', """);
}
return str;
}
// Java to HTML
public static String convertToHtmlValue(String str)
throws IOException
{
if ((str != null) && (!"".equals(str)))
{
str = replaceChar(str, '<', "<");
str = replaceChar(str, '>', ">");
str = replaceChar(str, '\'', "'");
str = replaceChar(str, '"', """);
str = replaceChar(str, '\n', "<BR>");
str = replaceChar(str, '\r', "");
}
return str;
}
public static String convertToJavaScriptHtmlValue(String str)
throws IOException
{
if ((str != null) && (!"".equals(str)))
{
str = replaceChar(str, '\'', "\\'");
str = replaceChar(str, '"', """);
str = replaceChar(str, '\n', "<BR>");
str = replaceChar(str, '\r', "");
}
return str;
}
/*************** 處理NULL字串 ***************/
public static String notNull(String str)
{
return str == null ? "" : str;
}
public static String notNull(String str, String replace)
{
return str == null ? replace : str;
}
留言列表