public ClassSource create ( final String source ) { checkNotNull ( source ) ; String trimmed = source . trim ( ) ; log . trace ( "Creating class-source from: {}" , trimmed ) ; // First try and parse the source as a URL try { return new ClassSourceImpl ( new URL ( trimmed ) , null , null ) ; } catch ( MalformedURLException e ) { log . trace ( "Not a URL" , e ) ; } // FIXME: This is _slightly_ problematic as if you have a valid file ref // FIXME: but the file is missing then it will be treated as inline instead of as a file // Then as a File try { File file = new File ( trimmed ) . getCanonicalFile ( ) ; if ( file . exists ( ) ) { return new ClassSourceImpl ( null , file , null ) ; } } catch ( IOException e ) { log . trace ( "Not a File" , e ) ; } // Else it is an inline return new ClassSourceImpl ( null , null , new InlineImpl ( source ) ) ; }
Create a class - source from the given source .