public String getLibrary ( final ODatabase < ? > db , final String iLanguage ) { if ( db == null ) // NO DB = NO LIBRARY return null ; final StringBuilder code = new StringBuilder ( ) ; final Set < String > functions = db . getMetadata ( ) . getFunctionLibrary ( ) . getFunctionNames ( ) ; for ( String fName : functions ) { final OFunction f = db . getMetadata ( ) . getFunctionLibrary ( ) . getFunction ( fName ) ; if ( f . getLanguage ( ) == null ) throw new OConfigurationException ( "Database function '" + fName + "' has no language" ) ; if ( f . getLanguage ( ) . equalsIgnoreCase ( iLanguage ) ) { final String def = getFunctionDefinition ( f ) ; if ( def != null ) { code . append ( def ) ; code . append ( "\n" ) ; } } } return code . length ( ) == 0 ? null : code . toString ( ) ; }
Formats the library of functions for a language .