/*************** 轉換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, '<', "&#060;");
str = replaceChar(str, '>', "&#062;");
str = replaceChar(str, '\'', "&#039;");
str = replaceChar(str, '"', "&#034;");
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, '"', "&#034;");
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;
}

Will(小威) 發表在 痞客邦 PIXNET 留言(0) 人氣()