public static MimeType getInstance ( String strMimeType ) { if ( strMimeType == null ) return ALL ; strMimeType = strMimeType . trim ( ) ; if ( "*" . equals ( strMimeType ) || strMimeType . length ( ) == 0 ) return ALL ; String [ ] arr = ListUtil . listToStringArray ( strMimeType , ' ' ) ; if ( arr . length == 0 ) return ALL ; String [ ] arrCT = ListUtil . listToStringArray ( arr [ 0 ] . trim ( ) , ' ' ) ; // subtype String type = null , subtype = null ; // type if ( arrCT . length >= 1 ) { type = arrCT [ 0 ] . trim ( ) ; if ( "*" . equals ( type ) ) type = null ; if ( arrCT . length >= 2 ) { subtype = arrCT [ 1 ] . trim ( ) ; if ( "*" . equals ( subtype ) ) subtype = null ; } } if ( arr . length == 1 ) return getInstance ( type , subtype , null ) ; final Map < String , String > properties = new HashMap < String , String > ( ) ; String entry ; String [ ] _arr ; for ( int i = 1 ; i < arr . length ; i ++ ) { entry = arr [ i ] . trim ( ) ; _arr = ListUtil . listToStringArray ( entry , ' ' ) ; if ( _arr . length >= 2 ) properties . put ( _arr [ 0 ] . trim ( ) . toLowerCase ( ) , _arr [ 1 ] . trim ( ) ) ; else if ( _arr . length == 1 && ! _arr [ 0 ] . trim ( ) . toLowerCase ( ) . equals ( "*" ) ) properties . put ( _arr [ 0 ] . trim ( ) . toLowerCase ( ) , "" ) ; } return getInstance ( type , subtype , properties ) ; }
returns a mimetype that match given string