package com.jeecms.cms.dao.assist.impl;

import org.apache.commons.lang.IllegalClassException;

public class SqlEscape {
/**
* 支持String,Integer,Character,Float,Double
*
@param obj
*
@return
*/
public static String escape(Object obj){
if (obj instanceof String||obj instanceof Integer || obj instanceof Character || obj instanceof Float || obj instanceof Double) {
String text = obj.toString();
StringBuffer sbf=new StringBuffer();
for (int i = 0; i < text.toCharArray().length; i++) {
sbf.append("\\").append(text.charAt(i));
}
return sbf.toString();
}else{
throw new IllegalClassException(String.class,obj);
}
}
}

新手,大神勿喷,有好的意见请回复!

相关文章:

  • 2021-07-12
  • 2022-12-23
  • 2021-11-08
  • 2021-05-24
  • 2021-05-28
  • 2022-01-04
  • 2021-08-18
猜你喜欢
  • 2021-11-30
  • 2023-02-03
  • 2022-12-23
  • 2021-11-18
  • 2021-12-10
  • 2022-01-21
相关资源
相似解决方案