天天看点

自定义EL表达式的函数

public class Functions {

    public static String clob2String(Object object){

        java.sql.Clob clob=null;

        if(object ==null)return "";

        if(object instanceof java.sql.Clob){

            clob=(java.sql.Clob)object;

        }else{

            return object.toString();

        }

        StringBuffer sb=new StringBuffer();

          try{

              if ( clob != null )

              {

                    java.io.Reader is = clob.getCharacterStream ();

                    java.io.BufferedReader br = new java.io.BufferedReader ( is );

                    String s;

                    while ((s=br.readLine ())!= null )

                    {

                        if(sb.length()==0){

                            sb.append(s) ;

                        }

                        else{

                            sb.append("\r\n"+s) ;

                        }

                    }

                    is.close();

                    br.close();

              }

              else{

                  return null;

              }

          }

          catch(Exception e){

              System.out.print(e);

              return null;

          }

          return sb.substring(0);

    }

    public static String clob2StringEscapeHTML(Object object){

        java.sql.Clob clob=null;

        if(object ==null)return "";

        if(object instanceof java.sql.Clob){

            clob=(java.sql.Clob)object;

        }else{

            return object.toString();

        }

        StringBuffer sb=new StringBuffer();

          try{

              if ( clob != null )

              {

                    java.io.Reader is = clob.getCharacterStream ();

                    java.io.BufferedReader br = new java.io.BufferedReader ( is );

                    String s;

                    while ((s=br.readLine ())!= null )

                    {

                        if(sb.length()==0){

                            sb.append(s) ;

                        }

                        else{

                            sb.append("<br/>"+s);

                        }

                    }

                    is.close();

                    br.close();

              }

              else{

                  return null;

              }

          }

          catch(Exception e){

              System.out.print(e);

              return null;

          }

          String str=sb.substring(0);

          str=str.replace(" ", "&nbsp;");

          return str;

    }

    public static String hiddenIP(String ipAddress){

        return ipAddress.replaceAll("\\.\\d{1,3}\\.\\d{1,3}$", ".*.*");

    }

继续阅读