signature:
public class CssLintProcessor { /** * Called when { @ link CssLintException } is thrown . Allows subclasses to re - throw this exception as a { @ link RuntimeException } or handle
 * it differently .
 * @ param e { @ link CssLintException } which has occurred .
 * @ param resource the processed resource which caused the exception . */
protected void onCssLintException ( final CssLintException e , final Resource resource ) { } }

implementation: final String uri = resource == null ? StringUtils . EMPTY : resource . getUri ( ) ; LOG . error ( "The following resource: " + uri + " has " + e . getErrors ( ) . size ( ) + " errors." ) ; for ( final CssLintError x : e . getErrors ( ) ) { LOG . error ( uri + " line " + x . getLine ( ) + " column " + x . getCol ( ) + ": " + x . getType ( ) + " " + x . getMessage ( ) ) ; }


signature:
public class NodeLessCssProcessor { /** * Creates process responsible for running lessc shell command by reading the file content from the sourceFilePath
 * @ param sourceFile
 * the source path of the file from where the lessc will read the less file .
 * @ throws IOException
 * when the process execution fails . */
private Process createProcess ( final File sourceFile ) throws IOException { } }

implementation: notNull ( sourceFile ) ; final String [ ] commandLine = getCommandLine ( sourceFile . getPath ( ) ) ; LOG . debug ( "CommandLine arguments: {}" , Arrays . asList ( commandLine ) ) ; return new ProcessBuilder ( commandLine ) . redirectErrorStream ( true ) . start ( ) ;


signature:
public class DefaultModelFactoryProvider { /** * { @ inheritDoc } */
@ Override public Map < String , WroModelFactory > provideModelFactories ( ) { } }

implementation: final Map < String , WroModelFactory > map = new HashMap < String , WroModelFactory > ( ) ; map . put ( GroovyModelFactory . ALIAS , new GroovyModelFactory ( ) ) ; map . put ( JsonModelFactory . ALIAS , new JsonModelFactory ( ) ) ; map . put ( SmartWroModelFactory . ALIAS , new SmartWroModelFactory ( ) ) ; return map ;


signature:
public class DustJs { /** * { @ inheritDoc } */
@ Override protected InputStream getCompilerAsStream ( ) throws IOException { } }

implementation: final String compilerPath = System . getProperty ( PARAM_COMPILER_PATH ) ; LOG . debug ( "compilerPath: {}" , compilerPath ) ; return StringUtils . isEmpty ( compilerPath ) ? getDefaultCompilerStream ( ) : new FileInputStream ( compilerPath ) ;


signature:
public class HoganJs { /** * { @ inheritDoc } */
@ Override public String compile ( final String content , final String optionalArgument ) { } }

implementation: return String . format ( "Hogan.cache['%s'] = %s;" , optionalArgument , super . compile ( content , "" ) ) ;


signature:
public class DefaultModelFactoryProvider { /** * { @ inheritDoc } */
public Map < String , WroModelFactory > provideModelFactories ( ) { } }

implementation: final Map < String , WroModelFactory > map = new HashMap < String , WroModelFactory > ( ) ; map . put ( XmlModelFactory . ALIAS , new XmlModelFactory ( ) ) ; return map ;


signature:
public class Selector { /** * Parses out the properties of a selector ' s body .
 * @ param contents The body ; for example , " border : solid 1px red ; color : blue ; " */
private Property [ ] parseProperties ( final String contents ) { } }

implementation:
final String [ ] parts = contents . split ( ";" ) ; final List < Property > resultsAsList = new ArrayList < Property > ( ) ; for ( String part : parts ) { try { // ignore empty parts
if ( ! StringUtils . isEmpty ( part . trim ( ) ) ) { resultsAsList . add ( new Property ( part ) ) ; } } catch ( final Exception e ) { LOG . warn ( e . getMessage ( ) , e ) ; } } return resultsAsList . toArray ( new Property [ resultsAsList . size ( ) ] ) ;


signature:
public class StopWatch { /** * Return an array of the data for tasks performed . */
public TaskInfo [ ] getTaskInfo ( ) { } }

implementation: if ( ! this . keepTaskList ) { throw new UnsupportedOperationException ( "Task info is not being kept!" ) ; } return ( TaskInfo [ ] ) this . taskList . toArray ( new TaskInfo [ this . taskList . size ( ) ] ) ;


signature:
public class StopWatch { /** * Return a string with a table describing all tasks performed . For custom reporting , call getTaskInfo ( ) and use the
 * task info directly . */
public String prettyPrint ( ) { } }

implementation: final StringBuffer sb = new StringBuffer ( shortSummary ( ) ) ; sb . append ( '\n' ) ; if ( ! this . keepTaskList ) { sb . append ( "No task info kept" ) ; } else { final TaskInfo [ ] tasks = getTaskInfo ( ) ; sb . append ( "-----------------------------------------\n" ) ; sb . append ( "ms     %     Task name\n" ) ; sb . append ( "-----------------------------------------\n" ) ; final NumberFormat nf = NumberFormat . getNumberInstance ( ) ; nf . setMinimumIntegerDigits ( 5 ) ; nf . setGroupingUsed ( false ) ; final NumberFormat pf = NumberFormat . getPercentInstance ( ) ; pf . setMinimumIntegerDigits ( 3 ) ; pf . setGroupingUsed ( false ) ; for ( final TaskInfo task : tasks ) { sb . append ( nf . format ( task . getTimeMillis ( ) ) + "  " ) ; final double totalTimeSeconds = getTotalTimeSeconds ( ) ; final double percentage = totalTimeSeconds == 0 ? 0 : task . getTimeSeconds ( ) / totalTimeSeconds ; sb . append ( pf . format ( percentage ) + "  " ) ; sb . append ( task . getTaskName ( ) + "\n" ) ; } } return sb . toString ( ) ;


signature:
public class TypeScriptCompiler { /** * Creates compilation command for provided typescript input .
 * @ param input
 * the TypeScript to compile into js .
 * @ return compilation command . */
private String getCompilationCommand ( final String input ) { } }

implementation: return String . format ( "compilerWrapper.compile(%s, %s)" , WroUtil . toJSMultiLineString ( input ) , ecmaScriptVersion ) ;


signature:
public class ResponseHeadersConfigurer { /** * Factory method which creates a { @ link ResponseHeadersConfigurer } containing headers used to disable cache . */
public static ResponseHeadersConfigurer noCache ( ) { } }

implementation: return new ResponseHeadersConfigurer ( ) { @ Override public void configureDefaultHeaders ( final Map < String , String > map ) { addNoCacheHeaders ( map ) ; } } ;


signature:
public class ResponseHeadersConfigurer { /** * Factory method which creates a { @ link ResponseHeadersConfigurer } containing headers used to disable cache in debug
 * mode . */
public static ResponseHeadersConfigurer fromConfig ( final WroConfiguration config ) { } }

implementation:
return new ResponseHeadersConfigurer ( config . getHeader ( ) ) { @ Override public void configureDefaultHeaders ( final Map < String , String > map ) { if ( config . isDebug ( ) ) { // prevent caching when in development mode
addNoCacheHeaders ( map ) ; } else { final Calendar cal = Calendar . getInstance ( ) ; cal . roll ( Calendar . YEAR , 1 ) ; map . put ( HttpHeader . CACHE_CONTROL . toString ( ) , DEFAULT_CACHE_CONTROL_VALUE ) ; map . put ( HttpHeader . EXPIRES . toString ( ) , WroUtil . toDateAsString ( cal . getTimeInMillis ( ) ) ) ; // TODO probably this is not a good idea to set this field which will have a different value when there will be
// more than one instance of wro4j .
map . put ( HttpHeader . LAST_MODIFIED . toString ( ) , WroUtil . toDateAsString ( getLastModifiedTimestamp ( ) ) ) ; } } ; } ;


signature:
public class ResponseHeadersConfigurer { /** * Parse header value & puts the found values in headersMap field .
 * @ param header
 * value to parse . */
private void parseHeader ( final String header ) { } }

implementation: LOG . debug ( "parseHeader: {}" , header ) ; final String headerName = header . substring ( 0 , header . indexOf ( ":" ) ) ; if ( ! headersMap . containsKey ( headerName ) ) { final String value = header . substring ( header . indexOf ( ":" ) + 1 ) ; headersMap . put ( headerName , StringUtils . trim ( value ) ) ; }


signature:
public class ResponseHeadersConfigurer { /** * Populates the map with headers used to disable cache . */
private static void addNoCacheHeaders ( final Map < String , String > map ) { } }

implementation: map . put ( HttpHeader . PRAGMA . toString ( ) , "no-cache" ) ; map . put ( HttpHeader . CACHE_CONTROL . toString ( ) , "no-cache" ) ; map . put ( HttpHeader . EXPIRES . toString ( ) , "0" ) ;


signature:
public class ResponseHeadersConfigurer { /** * Method called for each request and responsible for setting response headers , used mostly for cache control .
 * Override this method if you want to change the way headers are set . < br >
 * @ param response
 * { @ link HttpServletResponse } object . */
public void setHeaders ( final HttpServletResponse response ) { } }

implementation:
// Force resource caching as best as possible
for ( final Map . Entry < String , String > entry : headersMap . entrySet ( ) ) { response . setHeader ( entry . getKey ( ) , entry . getValue ( ) ) ; }


signature:
public class RhinoCoffeeScriptProcessor { /** * { @ inheritDoc } */
@ Override public void process ( final Resource resource , final Reader reader , final Writer writer ) throws IOException { } }

implementation: final String content = IOUtils . toString ( reader ) ; final CoffeeScript coffeeScript = enginePool . getObject ( ) ; try { writer . write ( coffeeScript . compile ( content ) ) ; } catch ( final Exception e ) { onException ( e ) ; final String resourceUri = resource == null ? StringUtils . EMPTY : "[" + resource . getUri ( ) + "]" ; LOG . error ( "Exception while applying " + getClass ( ) . getSimpleName ( ) + " processor on the " + resourceUri + " resource, no processing applied..." , e ) ; } finally { reader . close ( ) ; writer . close ( ) ; enginePool . returnObject ( coffeeScript ) ; }


signature:
public class PropertiesAndFilterConfigWroConfigurationFactory { /** * { @ inheritDoc } */
@ Override public Properties createProperties ( ) { } }

implementation:
// Merge Properties file content with the filterConfig content .
final Properties merged = new Properties ( ) ; try { final Properties props = newDefaultProperties ( ) ; if ( props != null ) { merged . putAll ( props ) ; } } catch ( final Exception e ) { LOG . warn ( "Cannot load properties from default location. Load propertis from filterConfig" , e ) ; } final Properties props = createPropertiesFromFilterConfig ( ) ; merged . putAll ( props ) ; return merged ;


signature:
public class RhinoUtils { /** * Creates a more detailed message based on { @ link RhinoException } thrown by rhino execution . The message will contain
 * a detailed description of the problem by inspecting the JSON value provided by exception .
 * @ param e
 * { @ link RhinoException } thrown by rhino execution .
 * @ return detailed string message . */
public static String createExceptionMessage ( final RhinoException e ) { } }

implementation: StringBuffer message = new StringBuffer ( "Could not execute the script because: \n" ) ; if ( e instanceof JavaScriptException ) { message . append ( toJson ( ( ( JavaScriptException ) e ) . getValue ( ) ) ) ; } else if ( e instanceof EcmaError ) { final EcmaError ecmaError = ( EcmaError ) e ; message . append ( String . format ( "Error message: %s at line: %s. \nSource: %s" , ecmaError . getErrorMessage ( ) , ecmaError . lineNumber ( ) , ecmaError . lineSource ( ) ) ) ; } else { message . append ( e . getMessage ( ) ) ; } return message . toString ( ) ;


signature:
public class RhinoUtils { /** * Recursively convert from native Rhino to JSON .
 * Recognizes JavaScript objects , arrays and primitives .
 * Special support for JavaScript dates : converts to { " $ date " : timestamp } in JSON .
 * Special support for MongoDB ObjectId : converts to { " $ oid " : " objectid " } in JSON .
 * Also recognizes JVM types : java . util . Map , java . util . Collection , java . util . Date .
 * @ param object
 * A Rhino native object
 * @ param indent
 * Whether to indent the JSON for human readability
 * @ return The JSON string */
public static String toJson ( final Object object , final boolean indent ) { } }

implementation: final StringBuilder s = new StringBuilder ( ) ; encode ( s , object , indent , indent ? 0 : - 1 ) ; return s . toString ( ) ;


signature:
public class WroUtil { /** * Retrieve pathInfo from a given location .
 * @ param request
 * @ param location
 * where to search contextPath .
 * @ return pathInfo value . */
public static String getPathInfoFromLocation ( final HttpServletRequest request , final String location ) { } }

implementation: if ( StringUtils . isEmpty ( location ) ) { throw new IllegalArgumentException ( "Location cannot be empty string!" ) ; } final String contextPath = request . getContextPath ( ) ; if ( contextPath != null ) { if ( startsWithIgnoreCase ( location , contextPath ) ) { return location . substring ( contextPath . length ( ) ) ; } else { return location ; } } final String noSlash = location . substring ( 1 ) ; final int nextSlash = noSlash . indexOf ( '/' ) ; if ( nextSlash == - 1 ) { return "" ; } return noSlash . substring ( nextSlash ) ;


signature:
public class WroUtil { /** * Creates a folder like implementation for a class . Ex : com . mycompany . MyClass - > com / mycompany /
 * @ param clazz
 * used as a base location for determining the package path .
 * @ return a string representation of the path where the class resides . */
public static String toPackageAsFolder ( final Class < ? > clazz ) { } }

implementation: Validate . notNull ( clazz , "Class cannot be null!" ) ; return clazz . getPackage ( ) . getName ( ) . replace ( '.' , '/' ) ;


signature:
public class WroUtil { /** * Check if a String starts with a specified prefix ( optionally case insensitive ) .
 * @ see java . lang . String # startsWith ( String )
 * @ param str
 * the String to check , may be null
 * @ param prefix
 * the prefix to find , may be null
 * @ param ignoreCase
 * indicates whether the compare should ignore case ( case insensitive ) or not .
 * @ return < code > true < / code > if the String starts with the prefix or both < code > null < / code > */
private static boolean startsWith ( final String str , final String prefix , final boolean ignoreCase ) { } }

implementation: if ( str == null || prefix == null ) { return ( str == null && prefix == null ) ; } if ( prefix . length ( ) > str . length ( ) ) { return false ; } return str . regionMatches ( ignoreCase , 0 , prefix , 0 , prefix . length ( ) ) ;


signature:
public class WroUtil { /** * Retrieve servletPath from a given location .
 * @ param location
 * where to search the servletPath .
 * @ return ServletPath string value . */
public static String getServletPathFromLocation ( final HttpServletRequest request , final String location ) { } }

implementation: return location . replace ( getPathInfoFromLocation ( request , location ) , StringUtils . EMPTY ) ;


signature:
public class WroUtil { /** * Analyze headers of the request and searches for mangled ( by proxy ) for " Accept - Encoding " header and its mangled
 * variations and gzip header value and its mangled variations .
 * @ return true if this request support gzip encoding . */
@ SuppressWarnings ( "unchecked" ) public static boolean isGzipSupported ( final HttpServletRequest request ) { } }

implementation: if ( request != null ) { final Enumeration < String > headerNames = request . getHeaderNames ( ) ; if ( headerNames != null ) { while ( headerNames . hasMoreElements ( ) ) { final String headerName = headerNames . nextElement ( ) ; final Matcher m = PATTERN_ACCEPT_ENCODING . matcher ( headerName ) ; if ( m . find ( ) ) { final String headerValue = request . getHeader ( headerName ) ; final Matcher mValue = PATTERN_GZIP . matcher ( headerValue ) ; return mValue . find ( ) ; } } } } return false ;


signature:
public class WroUtil { /** * Transforms a java multi - line string into javascript multi - line string . This technique was found at { @ link http
 * : / / stackoverflow . com / questions / 805107 / multiline - strings - in - javascript / }
 * @ param data
 * a string containing new lines .
 * @ return a string which being evaluated on the client - side will be treated as a correct multi - line string . */
public static String toJSMultiLineString ( final String data ) { } }

implementation:
final StringBuffer result = new StringBuffer ( "[" ) ; if ( data != null ) { final String [ ] lines = data . split ( "\n" ) ; if ( lines . length == 0 ) { result . append ( "\"\"" ) ; } for ( int i = 0 ; i < lines . length ; i ++ ) { final String line = lines [ i ] ; result . append ( "\"" ) ; result . append ( line . replace ( SEPARATOR_WINDOWS , "\\\\" ) . replace ( "\"" , "\\\"" ) . replaceAll ( "\\r|\\n" , "" ) ) ; // this is used to force a single line to have at least one new line ( otherwise cssLint fails ) .
if ( lines . length == 1 ) { result . append ( "\\n" ) ; } result . append ( "\"" ) ; if ( i < lines . length - 1 ) { result . append ( "," ) ; } } } result . append ( "].join(\"\\n\")" ) ; return result . toString ( ) ;


signature:
public class WroUtil { /** * Utility used to verify that requestURI matches provided path */
public static boolean matchesUrl ( final HttpServletRequest request , final String path ) { } }

implementation: final Pattern pattern = Pattern . compile ( ".*" + path + "[/]?" , Pattern . CASE_INSENSITIVE ) ; if ( request . getRequestURI ( ) != null ) { final Matcher m = pattern . matcher ( request . getRequestURI ( ) ) ; return m . matches ( ) ; } return false ;


signature:
public class WroUtil { /** * A factory method for creating a { @ link ResourceProcessor } based on provided { @ link ResourcePreProcessor } .
 * @ param preProcessor
 * { @ link ResourcePreProcessor } to use as a { @ link ResourceProcessor } .
 * @ return instance of { @ link ResourceProcessor } . */
public static ResourcePostProcessor newResourceProcessor ( final Resource resource , final ResourcePreProcessor preProcessor ) { } }

implementation: return new ResourcePostProcessor ( ) { public void process ( final Reader reader , final Writer writer ) throws IOException { preProcessor . process ( resource , reader , writer ) ; } } ;


signature:
public class WroUtil { /** * Load the regular expression stored in in regexp . properties resource file .
 * @ param key
 * the key of the regexp to load .
 * @ return regular expression value . */
public static String loadRegexpWithKey ( final String key ) { } }

implementation: InputStream stream = null ; try { stream = WroUtil . class . getResourceAsStream ( "regexp.properties" ) ; final Properties props = new RegexpProperties ( ) . load ( stream ) ; return props . getProperty ( key ) ; } catch ( final IOException e ) { throw new WroRuntimeException ( "Could not load pattern with key: " + key + " from property file" , e ) ; } finally { closeQuietly ( stream ) ; }


signature:
public class WroUtil { /** * Copy and close the reader and writer streams .
 * @ param reader
 * The source stream .
 * @ param writer
 * The destination stream .
 * @ throws IOException
 * If content cannot be copy . */
public static void safeCopy ( final Reader reader , final Writer writer ) throws IOException { } }

implementation: try { IOUtils . copy ( reader , writer ) ; } finally { IOUtils . closeQuietly ( reader ) ; IOUtils . closeQuietly ( writer ) ; }


signature:
public class WroUtil { /** * Creates a temp file which has a certain extension .
 * @ param extension
 * of the created temp file . */
public static File createTempFile ( final String extension ) { } }

implementation: try { final String fileName = String . format ( "wro4j-%s.%s" , UUID . randomUUID ( ) . toString ( ) , extension ) ; final File file = new File ( createTempDirectory ( ) , fileName ) ; file . createNewFile ( ) ; return file ; } catch ( final IOException e ) { throw WroRuntimeException . wrap ( e ) ; }


signature:
public class WroUtil { /** * Join two paths ( using unix separator ) and make sure to use exactly one separator ( by adding or removing one if required ) . */
public static String joinPath ( final String left , final String right ) { } }

implementation: String leftHand = left ; if ( ! left . endsWith ( SEPARATOR_UNIX ) ) { leftHand += SEPARATOR_UNIX ; } return leftHand + right . replaceFirst ( "^/(.*)" , "$1" ) ;


signature:
public class WroUtil { /** * Cleans the image url by trimming result and removing \ ' or \ " characters if such exists .
 * @ param imageUrl
 * to clean .
 * @ return cleaned image URL . */
public static final String cleanImageUrl ( final String imageUrl ) { } }

implementation: notNull ( imageUrl ) ; return imageUrl . replace ( '\'' , ' ' ) . replace ( '\"' , ' ' ) . trim ( ) ;


signature:
public class WroUtil { /** * Similar to { @ link FilenameUtils # getFullPath ( String ) } , but fixes the problem with Windows platform for situations
 * when the path starts with " / " ( servlet context relative resources ) which are resolved to " \ " on windows .
 * @ param path
 * to compute filePath from .
 * @ return full path from the provided path . */
public static final String getFullPath ( final String path ) { } }

implementation: final String fullPath = FilenameUtils . getFullPath ( path ) ; return replaceWithServletContextSeparatorIfNedded ( fullPath ) ;


signature:
public class WroUtil { /** * Similar to { @ link FilenameUtils # normalize ( String ) } , but fixes the problem with Windows platform for situations
 * when the path starts with " / " ( servlet context relative resources ) which are resolved to " \ " on windows .
 * @ param path
 * to compute filePath from .
 * @ return full path from the provided path . */
public static final String normalize ( final String path ) { } }

implementation: final String normalized = FilenameUtils . normalize ( path ) ; return replaceWithServletContextSeparatorIfNedded ( normalized ) ;


signature:
public class ServletContextAttributeHelper { /** * Factory method which uses default name for storing / retrieving attributes in { @ link ServletContext } . */
public static ServletContextAttributeHelper create ( final FilterConfig filterConfig ) { } }

implementation: Validate . notNull ( filterConfig ) ; final String nameFromParam = filterConfig . getInitParameter ( INIT_PARAM_NAME ) ; final String name = nameFromParam != null ? nameFromParam : DEFAULT_NAME ; return new ServletContextAttributeHelper ( filterConfig . getServletContext ( ) , name ) ;


signature:
public class ServletContextAttributeHelper { /** * Creates a unique name used as a key to store the attribute in { @ link ServletContext } .
 * @ param attribute
 * type of attribute .
 * @ return the name of the attribute used to store in servlet context .
 * @ VisibleForTesting */
final String getAttributeName ( final Attribute attribute ) { } }

implementation: Validate . notNull ( attribute ) ; return WroServletContextListener . class . getName ( ) + "-" + attribute . name ( ) + "-" + this . name ;


signature:
public class ServletContextAttributeHelper { /** * Sets the attribute into the servlet context . The name of the attribute will be computed for you . */
final void setAttribute ( final Attribute attribute , final Object object ) { } }

implementation: Validate . notNull ( attribute ) ; LOG . debug ( "setting attribute: {} with value: {}" , attribute , object ) ; Validate . isTrue ( attribute . isValid ( object ) , object + " is not of valid subType for attribute: " + attribute ) ; servletContext . setAttribute ( getAttributeName ( attribute ) , object ) ;


signature:
public class ServletContextAttributeHelper { /** * Remove all attributes from { @ link ServletContext } . */
public void clear ( ) { } }

implementation: LOG . debug ( "destroying servletContext: {}" , this . name ) ; for ( Attribute attribute : Attribute . values ( ) ) { servletContext . removeAttribute ( getAttributeName ( attribute ) ) ; }


signature:
public class DataUriGenerator { /** * Generate the dataUri as string associated to the passed InputStream with encoding & type based on provided
 * fileName . */
public String generateDataURI ( final InputStream inputStream , final String fileName ) throws IOException { } }

implementation:
final StringWriter writer = new StringWriter ( ) ; final byte [ ] bytes = IOUtils . toByteArray ( inputStream ) ; inputStream . close ( ) ; final String mimeType = getMimeType ( fileName ) ; // actually write
generateDataURI ( bytes , writer , mimeType ) ; return writer . toString ( ) ;


signature:
public class DataUriGenerator { /** * Generates a data URI from a byte array and outputs to the given writer .
 * @ param bytes
 * The array of bytes to output to the data URI .
 * @ param out
 * Where to output the data URI .
 * @ param mimeType
 * The MIME type to specify in the data URI .
 * @ throws java . io . IOException */
private void generateDataURI ( final byte [ ] bytes , final Writer out , final String mimeType ) throws IOException { } }

implementation:
// create the output
final StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( DATA_URI_PREFIX ) ; // add MIME type
buffer . append ( mimeType ) ; // output base64 - encoding
buffer . append ( ";base64," ) ; buffer . append ( Base64 . encodeBytes ( bytes ) ) ; // output to writer
out . write ( buffer . toString ( ) ) ;


signature:
public class ReportXmlFormatter { /** * Factory method for creating { @ link ReportXmlFormatter } .
 * @ param lintReport
 * { @ link LintReport } to build xml reports from . */
public static ReportXmlFormatter create ( final LintReport < LintItem > lintReport , final FormatterType formatterType ) { } }

implementation: return new ReportXmlFormatter ( lintReport , formatterType ) ;


signature:
public class ReportXmlFormatter { /** * Creates a report which handles the adaptation of type < F > to { @ link LintItem } .
 * @ param lintReport
 * { @ link LintReport } containing all lints .
 * @ param formatterType
 * the type of formatter to use .
 * @ param adapter
 * a { @ link Function } responsible for adapting a type < F > into { @ link LintItem } */
private static < F > ReportXmlFormatter createInternal ( final LintReport < F > lintReport , final FormatterType formatterType , final Function < F , LintItem > adapter ) { } }

implementation: Validate . notNull ( lintReport ) ; final LintReport < LintItem > report = new LintReport < LintItem > ( ) ; for ( final ResourceLintReport < F > reportItem : lintReport . getReports ( ) ) { final Collection < LintItem > lintItems = new ArrayList < LintItem > ( ) ; for ( final F lint : reportItem . getLints ( ) ) { try { LOG . debug ( "Adding lint: {}" , lint ) ; lintItems . add ( adapter . apply ( lint ) ) ; } catch ( final Exception e ) { throw WroRuntimeException . wrap ( e , "Problem while adapting lint item" ) ; } } report . addReport ( ResourceLintReport . create ( reportItem . getResourcePath ( ) , lintItems ) ) ; } return new ReportXmlFormatter ( report , formatterType ) ;


signature:
public class ReportXmlFormatter { /** * { @ inheritDoc } */
@ Override protected void buildDocument ( ) { } }

implementation: final Element rootElement = getDocument ( ) . createElement ( formatterType . rootElementName ) ; getDocument ( ) . appendChild ( rootElement ) ; for ( final ResourceLintReport < LintItem > resourceErrors : getLintReport ( ) . getReports ( ) ) { rootElement . appendChild ( createFileElement ( resourceErrors ) ) ; }


signature:
public class ReportXmlFormatter { /** * Creates a { @ link Node } containing informations about all errors associated to a single resource . */
private Node createFileElement ( final ResourceLintReport < LintItem > resourceErrors ) { } }

implementation: final Element fileElement = getDocument ( ) . createElement ( ELEMENT_FILE ) ; fileElement . setAttribute ( ATTR_NAME , resourceErrors . getResourcePath ( ) ) ; for ( final LintItem error : resourceErrors . getLints ( ) ) { fileElement . appendChild ( createIssueElement ( error ) ) ; } return fileElement ;


signature:
public class ReportXmlFormatter { /** * Creates a { @ link Node } containing a detailed description of an issue . */
private Node createIssueElement ( final LintItem error ) { } }

implementation: final Element issueElement = getDocument ( ) . createElement ( getIssueElementName ( ) ) ; final String column = String . valueOf ( error . getColumn ( ) ) ; if ( StringUtils . isNotBlank ( column ) ) { issueElement . setAttribute ( getColumnAttributeName ( ) , column ) ; } final String evidence = error . getEvidence ( ) ; if ( StringUtils . isNotBlank ( evidence ) ) { issueElement . setAttribute ( ATTR_EVIDENCE , evidence ) ; } final String line = String . valueOf ( error . getLine ( ) ) ; if ( StringUtils . isNotBlank ( line ) ) { issueElement . setAttribute ( ATTR_LINE , line ) ; } final String reason = error . getReason ( ) ; if ( StringUtils . isNotBlank ( reason ) ) { issueElement . setAttribute ( getReasonAttributeName ( ) , reason ) ; } final String severity = error . getSeverity ( ) ; if ( StringUtils . isNotBlank ( severity ) ) { issueElement . setAttribute ( ATTR_SEVERITY , severity ) ; } return issueElement ;


signature:
public class Context { /** * A context useful for running in web context ( inside a servlet container ) . */
public static Context webContext ( final HttpServletRequest request , final HttpServletResponse response , final FilterConfig filterConfig ) { } }

implementation: return new Context ( request , response , filterConfig ) ;


signature:
public class Context { /** * Associate a context with the CURRENT request cycle .
 * @ param context { @ link Context } to set . */
public static void set ( final Context context , final WroConfiguration config ) { } }

implementation: notNull ( context ) ; notNull ( config ) ; context . setConfig ( config ) ; final String correlationId = generateCorrelationId ( ) ; CORRELATION_ID . set ( correlationId ) ; CONTEXT_MAP . put ( correlationId , context ) ;


signature:
public class Context { /** * Remove context from the local thread . */
public static void unset ( ) { } }

implementation: final String correlationId = CORRELATION_ID . get ( ) ; if ( correlationId != null ) { CONTEXT_MAP . remove ( correlationId ) ; } CORRELATION_ID . remove ( ) ;


signature:
public class Context { /** * Decorates a callable with { @ link ContextPropagatingCallable } making it possible to access the { @ link Context } from
 * within the decorated callable .
 * @ param callable
 * the { @ link Callable } to decorate .
 * @ return the decorated callable . */
public static < T > Callable < T > decorate ( final Callable < T > callable ) { } }

implementation: return new ContextPropagatingCallable < T > ( callable ) ;


signature:
public class DefaultSynchronizedCacheStrategyDecorator { /** * Decorates the provided { @ link CacheStrategy } . The provided { @ link CacheStrategy } won ' t be decorated if the
 * operation is redundant . */
public static CacheStrategy < CacheKey , CacheValue > decorate ( final CacheStrategy < CacheKey , CacheValue > decorated ) { } }

implementation: return decorated instanceof DefaultSynchronizedCacheStrategyDecorator ? decorated : new DefaultSynchronizedCacheStrategyDecorator ( decorated ) ;


signature:
public class DefaultSynchronizedCacheStrategyDecorator { /** * Creates a { @ link CacheValue } based on provided content . */
private CacheValue computeCacheValueByContent ( final String content ) { } }

implementation: String hash = null ; try { if ( content != null ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Content to fingerprint: [{}]" , StringUtils . abbreviate ( content , 30 ) ) ; } hash = hashStrategy . getHash ( new ByteArrayInputStream ( content . getBytes ( ) ) ) ; } final CacheValue entry = CacheValue . valueOf ( content , hash ) ; LOG . debug ( "computed entry: {}" , entry ) ; return entry ; } catch ( final IOException e ) { throw new RuntimeException ( "Should never happen" , e ) ; }


signature:
public class ResourceWatcher { /** * Will try an asynchronous check if the async configuration is enabled . If async check is not configured , a
 * synchronous check will be performed . The async check assumes that the { @ link ResourceWatcherRequestHandler } is
 * enabled .
 * If the async check is not allowed ( the request was not passed through { @ link WroFilter } ) - no check will be
 * performed . This is important for use - cases when wro resource is included using a taglib which performs a wro api
 * call directly , without being invoked through { @ link WroFilter } .
 * @ return true if the actual check invocation was performed . This is important to decide if the resource change
 * should be skipped or not . */
public boolean tryAsyncCheck ( final CacheKey cacheKey ) { } }

implementation: boolean checkInvoked = false ; if ( context . getConfig ( ) . isResourceWatcherAsync ( ) ) { if ( isAsyncCheckAllowed ( ) ) { LOG . debug ( "Checking resourceWatcher asynchronously..." ) ; final Callable < Void > callable = createAsyncCheckCallable ( cacheKey ) ; submit ( callable ) ; checkInvoked = true ; } } else { LOG . debug ( "Async check not allowed. Falling back to sync check." ) ; check ( cacheKey ) ; checkInvoked = true ; } return checkInvoked ;


signature:
public class ResourceWatcher { /** * Check if resources from a group were changed . If a change is detected , the changeListener will be invoked .
 * @ param cacheKey
 * the cache key which was requested . The key contains the groupName which has to be checked for changes . */
public void check ( final CacheKey cacheKey , final Callback callback ) { } }

implementation: notNull ( cacheKey ) ; LOG . debug ( "started" ) ; final StopWatch watch = new StopWatch ( ) ; watch . start ( "detect changes" ) ; try { final Group group = new WroModelInspector ( modelFactory . create ( ) ) . getGroupByName ( cacheKey . getGroupName ( ) ) ; if ( isGroupChanged ( group . collectResourcesOfType ( cacheKey . getType ( ) ) , callback ) ) { callback . onGroupChanged ( cacheKey ) ; cacheStrategy . put ( cacheKey , null ) ; } resourceChangeDetector . reset ( ) ; } catch ( final Exception e ) { onException ( e ) ; } finally { watch . stop ( ) ; LOG . debug ( "resource watcher info: {}" , watch . prettyPrint ( ) ) ; }


signature:
public class ResourceWatcher { /** * Invoked when exception occurs . */
protected void onException ( final Exception e ) { } }

implementation:
// not using ERROR log intentionally , since this error is not that important
LOG . info ( "Could not check for resource changes because: {}" , e . getMessage ( ) ) ; LOG . debug ( "[FAIL] detecting resource change " , e ) ;


signature:
public class ResourceWatcher { /** * Will check if a given resource was changed and will invoke the appropriate callback . */
private void checkResourceChange ( final Resource resource , final Group group , final Callback callback , final AtomicBoolean isChanged ) throws Exception { } }

implementation: if ( isChanged ( resource , group . getName ( ) ) ) { isChanged . compareAndSet ( false , true ) ; callback . onResourceChanged ( resource ) ; lifecycleCallback . onResourceChanged ( resource ) ; }


signature:
public class ResourceWatcher { /** * Check if the resource was changed from previous run . The implementation uses resource content digest ( hash ) to
 * check for change .
 * @ param resource
 * the { @ link Resource } to check .
 * @ return true if the resource was changed . */
private boolean isChanged ( final Resource resource , final String groupName ) { } }

implementation:
boolean changed = false ; try { final String uri = resource . getUri ( ) ; // using AtomicBoolean because we need to mutate this variable inside an anonymous class .
final AtomicBoolean changeDetected = new AtomicBoolean ( resourceChangeDetector . checkChangeForGroup ( uri , groupName ) ) ; if ( ! changeDetected . get ( ) && resource . getType ( ) == ResourceType . CSS ) { final Reader reader = new InputStreamReader ( locatorFactory . locate ( uri ) ) ; LOG . debug ( "\tCheck @import directive from {}" , resource ) ; createCssImportProcessor ( changeDetected , groupName ) . process ( resource , reader , new StringWriter ( ) ) ; } changed = changeDetected . get ( ) ; } catch ( final IOException e ) { LOG . debug ( "[FAIL] Cannot check {} resource (Exception message: {}). Assuming it is unchanged..." , resource , e . getMessage ( ) ) ; } LOG . debug ( "resource={}, changed={}" , resource . getUri ( ) , changed ) ; return changed ;


signature:
public class ResourceChangeInfo { /** * Updates the hash associated with the resource for a give groupName .
 * @ param hash
 * the most recent computed hash .
 * @ param groupName
 * name of the group for which the change of resource is detected . */
public void updateHashForGroup ( final String hash , final String groupName ) { } }

implementation:
notNull ( groupName ) ; this . currentHash = hash ; if ( isChangedHash ( ) ) { LOG . debug ( "Group {} has changed" , groupName ) ; // remove all persisted groups . Starting over . .
groups . clear ( ) ; }


signature:
public class Group { /** * Check if the group has at least one resource of some type .
 * @ param resourceType
 * type of the searched resource .
 * @ return true if at least one resource of some type exists . */
public final boolean hasResourcesOfType ( final ResourceType resourceType ) { } }

implementation: notNull ( resourceType , "ResourceType cannot be null!" ) ; for ( final Resource resource : resources ) { if ( resourceType . equals ( resource . getType ( ) ) ) { return true ; } } return false ;


signature:
public class Group { /** * Replace one resource with a list of other resources . The use case is related to wildcard expander functionality ,
 * when resources containing wildcard are replaced with a list of wildcard - free resources . The order of resources is
 * preserved .
 * The implementation is synchronized , because it mutates the collection .
 * @ param resource
 * to replace .
 * @ param expandedResources
 * a list of resources to replace . If this list is empty , the result is similar to removing the resource from
 * the group .
 * @ throws IllegalArgumentException
 * when a missing resources is to be replaced . */
public void replace ( final Resource resource , final List < Resource > expandedResources ) { } }

implementation:
LOG . debug ( "replacing resource {} with expanded resources: {}" , resource , expandedResources ) ; notNull ( resource ) ; notNull ( expandedResources ) ; synchronized ( this ) { boolean found = false ; // use set to avoid duplicates
final Set < Resource > result = new LinkedHashSet < Resource > ( ) ; for ( final Resource resourceItem : resources ) { if ( resourceItem . equals ( resource ) ) { found = true ; for ( final Resource expandedResource : expandedResources ) { // preserve minimize flag .
expandedResource . setMinimize ( resource . isMinimize ( ) ) ; result . add ( expandedResource ) ; } } else { result . add ( resourceItem ) ; } } // if no resources found , an invalid replace is performed
if ( ! found ) { throw new IllegalArgumentException ( "Cannot replace resource: " + resource + " for group: " + this + " because the resource is not a part of this group." ) ; } // update resources with newly built list .
setResources ( new ArrayList < Resource > ( result ) ) ; }


signature:
public class Group { /** * Add a { @ link Resource } to the collection of resources associated with this group .
 * The implementation is synchronized , because it mutates the collection .
 * @ param resource
 * { @ link Resource } to add to this group ( at the end ) .
 * @ return the reference to Group ( fluent interface ) . */
public Group addResource ( final Resource resource ) { } }

implementation: notNull ( resource ) ; synchronized ( this ) { if ( ! hasResource ( resource ) ) { resources . add ( resource ) ; } else { LOG . debug ( "Resource {} is already contained in this group, skipping it." , resource ) ; } } return this ;


signature:
public class Group { /** * This method will replace all earlier defined resources with the provided list of resources .
 * The implementation is synchronized , because it mutates the collection .
 * @ param resources
 * the resources to replace the underlying resources . */
public final void setResources ( final List < Resource > resources ) { } }

implementation: notNull ( resources ) ; synchronized ( this ) { this . resources . clear ( ) ; for ( final Resource resource : resources ) { addResource ( resource ) ; } }


signature:
public class AbstractConfigurableStrategySupport { /** * Utility method which copies all entries from source into target . Entries with the same keys from target will be
 * overridden with entries from source . This operation is similar to { @ link Map # putAll ( Map ) } , but it doesn ' t require
 * changing generics to construction like
 * < pre >
 * < ? extends String , ? extends S >
 * < / pre >
 * @ param source
 * the map from where the entries will be copied into target .
 * @ param target
 * the map where to put entries from source . */
protected final void copyAll ( final Map < String , S > source , final Map < String , S > target ) { } }

implementation: notNull ( source ) ; notNull ( target ) ; for ( final Map . Entry < String , S > entry : source . entrySet ( ) ) { target . put ( entry . getKey ( ) , entry . getValue ( ) ) ; }


signature:
public class NodeTypeScriptProcessor { /** * Creates process responsible for running tsc shell command by reading the file content from the sourceFilePath
 * @ param sourceFile
 * the source path of the file from where the tsc will read the typescript file .
 * @ param destFile
 * the destination of the compiled file .
 * @ throws IOException
 * when the process execution fails . */
private Process createProcess ( final File sourceFile , final File destFile ) throws IOException { } }

implementation:
notNull ( sourceFile ) ; final String [ ] commandLine = getCommandLine ( sourceFile . getPath ( ) , destFile . getPath ( ) ) ; LOG . debug ( "CommandLine arguments: {}" , Arrays . asList ( commandLine ) ) ; final Process process = new ProcessBuilder ( commandLine ) . redirectErrorStream ( true ) . start ( ) ; // Gobblers responsible for reading stream to avoid blocking of the process when the buffer is full .
final StreamGobbler errorGobbler = new StreamGobbler ( process . getErrorStream ( ) , "ERROR" ) ; // any output ?
final StreamGobbler outputGobbler = new StreamGobbler ( process . getInputStream ( ) , "OUTPUT" ) ; // kick them off
errorGobbler . start ( ) ; outputGobbler . start ( ) ; return process ;


signature:
public class NodeTypeScriptProcessor { /** * Creates the platform specific arguments to run the < code > tsc < / code > shell utility . Default implementation handles
 * windows and unix platforms .
 * @ return arguments for command line . The implementation will take care of OS differences . */
protected String [ ] getCommandLine ( final String filePath , final String outFilePath ) { } }

implementation: return isWindows ? buildArgumentsForWindows ( filePath , outFilePath ) : buildArgumentsForUnix ( filePath , outFilePath ) ;


signature:
public class UglifyJs { /** * Initialize script builder for evaluation . */
private RhinoScriptBuilder initScriptBuilder ( ) { } }

implementation:
// TODO : Find a way to encapsulate this code
RhinoScriptBuilder builder = null ; try { if ( scope == null ) { builder = RhinoScriptBuilder . newChain ( ) . addJSON ( ) . evaluateChain ( UglifyJs . class . getResourceAsStream ( "init.js" ) , "initScript" ) . evaluateChain ( getScriptAsStream ( ) , DEFAULT_UGLIFY_JS ) ; scope = builder . getScope ( ) ; } else { builder = RhinoScriptBuilder . newChain ( scope ) ; } return builder ; } catch ( final Exception ex ) { throw new IllegalStateException ( "Failed initializing js" , ex ) ; }


signature:
public class Base64 { /** * Performs Base64 encoding on the < code > raw < / code > ByteBuffer , writing it to the < code > encoded < / code > CharBuffer .
 * This is an experimental feature . Currently it does not pass along any options ( such as { @ link # DO _ BREAK _ LINES } or
 * { @ link # GZIP } .
 * @ param raw input buffer
 * @ param encoded output buffer
 * @ since 2.3 */
public static void encode ( final java . nio . ByteBuffer raw , final java . nio . CharBuffer encoded ) { } }

implementation: final byte [ ] raw3 = new byte [ 3 ] ; final byte [ ] enc4 = new byte [ 4 ] ; while ( raw . hasRemaining ( ) ) { final int rem = Math . min ( 3 , raw . remaining ( ) ) ; raw . get ( raw3 , 0 , rem ) ; Base64 . encode3to4 ( enc4 , raw3 , rem , Base64 . NO_OPTIONS ) ; for ( int i = 0 ; i < 4 ; i ++ ) { encoded . put ( ( char ) ( enc4 [ i ] & 0xFF ) ) ; } } // end input remaining


signature:
public class Base64 { /** * Serializes an object and returns the Base64 - encoded version of that serialized object .
 * As of v 2.3 , if the object cannot be serialized or there is another error , the method will throw an
 * java . io . IOException . < b > This is new to v2.3 ! < / b > In earlier versions , it just returned a null value , but in
 * retrospect that ' s a pretty poor way to handle it .
 * The object is not GZip - compressed before being encoded .
 * @ param serializableObject The object to encode
 * @ return The Base64 - encoded object
 * @ throws java . io . IOException if there is an error
 * @ throws NullPointerException if serializedObject is null
 * @ since 1.4 */
public static String encodeObject ( final java . io . Serializable serializableObject ) throws java . io . IOException { } }

implementation: return encodeObject ( serializableObject , NO_OPTIONS ) ;


signature:
public class XmlModelFactory { /** * Initialize the map */
private void processGroups ( final Document document ) { } }

implementation:
// handle imports
final NodeList groupNodeList = document . getElementsByTagName ( TAG_GROUP ) ; for ( int i = 0 ; i < groupNodeList . getLength ( ) ; i ++ ) { final Element groupElement = ( Element ) groupNodeList . item ( i ) ; final String name = groupElement . getAttribute ( ATTR_GROUP_NAME ) ; allGroupElements . put ( name , groupElement ) ; }


signature:
public class XmlModelFactory { /** * Recursive method . Add the parsed element group to the group collection . If the group contains group - ref element ,
 * parse recursively this group .
 * @ param element
 * Group Element to parse .
 * @ param groups
 * list of parsed groups where the parsed group is added . .
 * @ return list of resources associated with this resource */
private Collection < Resource > parseGroup ( final Element element ) { } }

implementation:
final String name = element . getAttribute ( ATTR_GROUP_NAME ) ; final String isAbstractAsString = element . getAttribute ( ATTR_GROUP_ABSTRACT ) ; final boolean isAbstractGroup = StringUtils . isNotEmpty ( isAbstractAsString ) && Boolean . valueOf ( isAbstractAsString ) ; if ( groupsInProcess . contains ( name ) ) { throw new RecursiveGroupDefinitionException ( "Infinite Recursion detected for the group: " + name + ". Recursion path: " + groupsInProcess ) ; } LOG . debug ( "\tadding group: {}" , name ) ; groupsInProcess . add ( name ) ; // skip if this group is already parsed
final Group parsedGroup = new WroModelInspector ( model ) . getGroupByName ( name ) ; if ( parsedGroup != null ) { // remove before returning
// this group is parsed , remove from unparsed groups collection
groupsInProcess . remove ( name ) ; return parsedGroup . getResources ( ) ; } final Group group = createGroup ( element ) ; // this group is parsed , remove from unparsed collection
groupsInProcess . remove ( name ) ; if ( ! isAbstractGroup ) { // add only non abstract groups
model . addGroup ( group ) ; } return group . getResources ( ) ;


signature:
public class XmlModelFactory { /** * Creates a group and all its associated resources .
 * @ param element
 * Group element to parse .
 * @ return fully initialized group */
protected Group createGroup ( final Element element ) { } }

implementation: final String name = element . getAttribute ( ATTR_GROUP_NAME ) ; final Group group = new Group ( name ) ; final List < Resource > resources = new ArrayList < Resource > ( ) ; final NodeList resourceNodeList = element . getChildNodes ( ) ; for ( int i = 0 ; i < resourceNodeList . getLength ( ) ; i ++ ) { final Node node = resourceNodeList . item ( i ) ; if ( node instanceof Element ) { final Element resourceElement = ( Element ) node ; parseResource ( resourceElement , resources ) ; } } group . setResources ( resources ) ; return group ;


signature:
public class XmlModelFactory { /** * Creates a resource from a given resourceElement . It can be css , js . If resource tag name is group - ref , the method
 * will start a recursive computation .
 * @ param resources
 * list of parsed resources where the parsed resource is added . */
private void parseResource ( final Element resourceElement , final Collection < Resource > resources ) { } }

implementation:
final String tagName = resourceElement . getTagName ( ) ; final String uri = resourceElement . getTextContent ( ) ; if ( TAG_GROUP_REF . equals ( tagName ) ) { // uri in this case is the group name
resources . addAll ( getResourcesForGroup ( uri ) ) ; } if ( getResourceType ( resourceElement ) != null ) { final Resource resource = createResource ( resourceElement ) ; LOG . debug ( "\t\tadding resource: {}" , resource ) ; resources . add ( resource ) ; }


signature:
public class XmlModelFactory { /** * Creates a resource from a given resourceElement . The element is guaranteed to be of a simple non - recursive type
 * ( i . e . css or js ) .
 * @ param resourceElement
 * Resource element to parse . */
protected Resource createResource ( final Element resourceElement ) { } }

implementation: final String uri = resourceElement . getTextContent ( ) ; final String minimizeAsString = resourceElement . getAttribute ( ATTR_MINIMIZE ) ; final boolean minimize = StringUtils . isEmpty ( minimizeAsString ) || Boolean . valueOf ( minimizeAsString ) ; final Resource resource = Resource . create ( uri , getResourceType ( resourceElement ) ) ; resource . setMinimize ( minimize ) ; return resource ;


signature:
public class XmlModelFactory { /** * Search for all resources for a group with a given name . */
private Collection < Resource > getResourcesForGroup ( final String groupName ) { } }

implementation: final WroModelInspector modelInspector = new WroModelInspector ( model ) ; final Group foundGroup = modelInspector . getGroupByName ( groupName ) ; if ( foundGroup == null ) { final Element groupElement = allGroupElements . get ( groupName ) ; if ( groupElement == null ) { throw new WroRuntimeException ( "Invalid group-ref: " + groupName ) ; } return parseGroup ( groupElement ) ; } return foundGroup . getResources ( ) ;


signature:
public class DefaultHashStrategyProvider { /** * { @ inheritDoc } */
public Map < String , HashStrategy > provideHashStrategies ( ) { } }

implementation: final Map < String , HashStrategy > map = new HashMap < String , HashStrategy > ( ) ; map . put ( CRC32HashStrategy . ALIAS , new CRC32HashStrategy ( ) ) ; map . put ( MD5HashStrategy . ALIAS , new MD5HashStrategy ( ) ) ; map . put ( SHA1HashStrategy . ALIAS , new SHA1HashStrategy ( ) ) ; return map ;


signature:
public class CoffeeScriptProcessor { /** * { @ inheritDoc } */
@ Override protected ResourcePreProcessor createFallbackProcessor ( ) { } }

implementation: LOG . debug ( "Node CoffeeScript is not supported. Using fallback Rhino processor" ) ; return new LazyProcessorDecorator ( new LazyInitializer < ResourcePreProcessor > ( ) { @ Override protected ResourcePreProcessor initialize ( ) { return new RhinoCoffeeScriptProcessor ( ) ; } } ) ;


signature:
public class CssUrlRewritingProcessor { /** * Replace provided url with the new url if needed .
 * @ param cssUri
 * Uri of the parsed css .
 * @ param imageUrl
 * to replace .
 * @ return replaced url . */
@ Override protected String replaceImageUrl ( final String cssUri , final String imageUrl ) { } }

implementation:
// Can be null when using standalone context .
final String contextPath = context . getRequest ( ) != null ? context . getRequest ( ) . getContextPath ( ) : null ; final RewriterContext rewriterContext = new RewriterContext ( ) . setAggregatedFolderPath ( context . getAggregatedFolderPath ( ) ) . setProxyPrefix ( getUrlPrefix ( ) ) . setContextPath ( contextPath ) ; return new ImageUrlRewriter ( rewriterContext ) . rewrite ( cssUri , imageUrl ) ;


signature:
public class MoreCollectors { /** * use { @ link com . google . common . collect . Multimaps # toMultimap ( Function , Function , Supplier ) } if using guava 21.0 + */
@ Deprecated public static < T , K , U , M extends Multimap < K , U > > Collector < T , ? , M > toMultimap ( Function < ? super T , ? extends K > keyMapper , Function < ? super T , ? extends U > valueMapper , Supplier < M > supplier ) { } }

implementation: BiConsumer < M , T > accumulator = ( multimap , element ) -> multimap . put ( keyMapper . apply ( element ) , valueMapper . apply ( element ) ) ; BinaryOperator < M > finisher = ( m1 , m2 ) -> { m1 . putAll ( m2 ) ; return m1 ; } ; return new CollectorImpl < > ( supplier , accumulator , finisher , CH_ID ) ;


signature:
public class MoreFunctions { /** * mainly use for { @ link Stream # parallel ( ) } with specific thread pool
 * see https : / / stackoverflow . com / questions / 21163108 / custom - thread - pool - in - java - 8 - parallel - stream */
public static < R , X extends Throwable > R supplyParallel ( ForkJoinPool pool , ThrowableSupplier < R , X > func ) throws X { } }

implementation:
checkNotNull ( pool ) ; Throwable [ ] throwable = { null } ; ForkJoinTask < R > task = pool . submit ( ( ) -> { try { return func . get ( ) ; } catch ( Throwable e ) { throwable [ 0 ] = e ; return null ; } } ) ; R r ; try { r = task . get ( ) ; } catch ( ExecutionException | InterruptedException impossible ) { throw new AssertionError ( impossible ) ; } if ( throwable [ 0 ] != null ) { // noinspection unchecked
throw ( X ) throwable [ 0 ] ; } return r ;


signature:
public class MoreFutures { /** * @ see # tryWait ( Iterable , long , TimeUnit )
 * @ throws TryWaitFutureUncheckedException if not all calls are successful . */
@ Nonnull public static < F extends Future < V > , V > Map < F , V > tryWait ( @ Nonnull Iterable < F > futures , @ Nonnull Duration duration ) throws TryWaitFutureUncheckedException { } }

implementation: checkNotNull ( futures ) ; checkNotNull ( duration ) ; return tryWait ( futures , duration . toNanos ( ) , NANOSECONDS ) ;


signature:
public class MoreFutures { /** * A typical usage :
 * { @ code < pre >
 * / / a fail - safe example
 * List < Future < User > > list = doSomeAsyncTasks ( ) ;
 * Map < Future < User > , User > success ;
 * try {
 * success = tryWait ( list , 1 , SECONDS ) ;
 * } catch ( TryWaitUncheckedException e ) {
 * success = e . getSuccess ( ) ; / / there are still some success
 * / / a fail - fast example
 * List < Future < User > > list = doSomeAsyncTasks ( ) ;
 * / / don ' t try / catch the exception it throws .
 * Map < Future < User > , User > success ; = tryWait ( list , 1 , SECONDS ) ;
 * < / pre > }
 * @ throws TryWaitUncheckedException if not all calls are successful . */
@ Nonnull public static < F extends Future < V > , V > Map < F , V > tryWait ( @ Nonnull Iterable < F > futures , @ Nonnegative long timeout , @ Nonnull TimeUnit unit ) throws TryWaitFutureUncheckedException { } }

implementation: checkNotNull ( futures ) ; checkArgument ( timeout > 0 ) ; checkNotNull ( unit ) ; return tryWait ( futures , timeout , unit , it -> it , TryWaitFutureUncheckedException :: new ) ;


signature:
public class MoreFutures { /** * @ see # tryWait ( Iterable , long , TimeUnit , ThrowableFunction )
 * @ throws TryWaitUncheckedException if not all calls are successful . */
@ Nonnull public static < K , V , X extends Throwable > Map < K , V > tryWait ( @ Nonnull Iterable < K > keys , @ Nonnull Duration duration , @ Nonnull ThrowableFunction < K , Future < V > , X > asyncFunc ) throws X , TryWaitUncheckedException { } }

implementation: checkNotNull ( keys ) ; checkNotNull ( duration ) ; checkNotNull ( asyncFunc ) ; return tryWait ( keys , duration . toNanos ( ) , NANOSECONDS , asyncFunc ) ;


signature:
public class MoreFutures { /** * A typical usage :
 * { @ code < pre >
 * / / a fail - safe example
 * List < Integer > list = getSomeIds ( ) ;
 * Map < Integer , User > success ;
 * try {
 * success = tryWait ( list , 1 , SECONDS , id - > executor . submit ( ( ) - > retrieve ( id ) ) ) ;
 * } catch ( TryWaitUncheckedException e ) {
 * success = e . getSuccess ( ) ; / / there are still some success
 * / / a fail - fast example
 * List < Integer > list = getSomeIds ( ) ;
 * / / don ' t try / catch the exception it throws .
 * Map < Integer , User > success = tryWait ( list , 1 , SECONDS , id - > executor . submit ( ( ) - > retrieve ( id ) ) ) ;
 * < / pre > }
 * @ throws TryWaitUncheckedException if not all calls are successful . */
@ Nonnull public static < K , V , X extends Throwable > Map < K , V > tryWait ( @ Nonnull Iterable < K > keys , @ Nonnegative long timeout , @ Nonnull TimeUnit unit , @ Nonnull ThrowableFunction < K , Future < V > , X > asyncFunc ) throws X , TryWaitUncheckedException { } }

implementation: return tryWait ( keys , timeout , unit , asyncFunc , TryWaitUncheckedException :: new ) ;


signature:
public class ConcurrentExecutors { /** * Creates a { @ link ConcurrentExecutor } with the given name ( used as a
 * prefix for creating thread ) , and given timeout for running threads . If a
 * thread did not process a job within the given timeout , the thread is
 * terminated .
 * @ param name
 * @ param timeout
 * @ param unit
 * @ return the { @ link ConcurrentExecutor } associated with the given
 * parameters */
public static ConcurrentExecutor create ( String name , long timeout , TimeUnit unit ) { } }

implementation: return new ConcurrentExecutorImpl ( name , timeout , unit ) ;


signature:
public class ElkTimer { /** * Print logging information for the timer . The log only shows the recorded
 * time of the completed start - stop cycles . If the timer is still running ,
 * then it will not be stopped to add the currently measured time to the
 * output but a warning will be logged .
 * @ param logger
 * @ param priority */
public void log ( Logger logger , LogLevel priority ) { } }

implementation: if ( LoggerWrap . isEnabledFor ( logger , priority ) ) { String timerLabel ; if ( threadId != 0 ) { timerLabel = name + " (thread " + threadId + ")" ; } else if ( threadCount > 1 ) { timerLabel = name + " (over " + threadCount + " threads)" ; } else { timerLabel = name ; } if ( todoFlags == RECORD_NONE ) { LoggerWrap . log ( logger , priority , "Timer " + timerLabel + " recorded " + measurements + " run(s), no times taken" ) ; } else { String labels = "" ; String values = "" ; String separator ; if ( ( todoFlags & RECORD_CPUTIME ) != 0 && threadId != 0 ) { labels += "CPU" ; values += totalCpuTime / 1000000 ; separator = "/" ; } else { separator = "" ; } if ( ( todoFlags & RECORD_WALLTIME ) != 0 ) { labels += separator + "Wall" ; values += separator + totalWallTime / 1000000 ; } if ( ( todoFlags & RECORD_CPUTIME ) != 0 && threadId != 0 ) { labels += "/CPU avg" ; values += "/" + ( float ) ( totalCpuTime ) / measurements / 1000000 ; } if ( ( todoFlags & RECORD_WALLTIME ) != 0 ) { labels += "/Wall avg" ; values += "/" + ( float ) ( totalWallTime ) / measurements / 1000000 ; } if ( threadCount > 1 ) { if ( ( todoFlags & RECORD_CPUTIME ) != 0 && threadId != 0 ) { labels += "/CPU per thread" ; values += "/" + ( float ) ( totalCpuTime ) / threadCount / 1000000 ; } if ( ( todoFlags & RECORD_WALLTIME ) != 0 ) { labels += "/Wall per thread" ; values += "/" + ( float ) ( totalWallTime ) / threadCount / 1000000 ; } } LoggerWrap . log ( logger , priority , "Time for " + timerLabel + " for " + measurements + " run(s) " + labels + " (ms): " + values ) ; } if ( isRunning ) { logger . warn ( "Timer " + timerLabel + " logged while it was still running" ) ; } }


signature:
public class ElkTimer { /** * Stop a timer of the given string name for the given thread . If no such
 * timer exists , - 1 will be returned . Otherwise the return value is the CPU
 * time that was measured .
 * @ param timerName
 * the name of the timer
 * @ param todoFlags
 * @ param threadId
 * of the thread to track , or 0 if only system clock should be
 * tracked
 * @ return CPU time if timer existed and was running , and - 1 otherwise */
public static long stopNamedTimer ( String timerName , int todoFlags , long threadId ) { } }

implementation: ElkTimer key = new ElkTimer ( timerName , todoFlags , threadId ) ; if ( registeredTimers . containsKey ( key ) ) { return registeredTimers . get ( key ) . stop ( ) ; } else { return - 1 ; }


signature:
public class ElkTimer { /** * Get a timer of the given string name that takes all possible times
 * ( todos ) for the current thread . If no such timer exists yet , then it will
 * be newly created .
 * @ param timerName
 * the name of the timer
 * @ return timer */
public static ElkTimer getNamedTimer ( String timerName ) { } }

implementation: return getNamedTimer ( timerName , RECORD_ALL , Thread . currentThread ( ) . getId ( ) ) ;


signature:
public class ElkTimer { /** * Get a timer of the given string name and todos for the current thread . If
 * no such timer exists yet , then it will be newly created .
 * @ param timerName
 * the name of the timer
 * @ param todoFlags
 * @ return timer */
public static ElkTimer getNamedTimer ( String timerName , int todoFlags ) { } }

implementation: return getNamedTimer ( timerName , todoFlags , Thread . currentThread ( ) . getId ( ) ) ;


signature:
public class ElkTimer { /** * Get a timer of the given string name for the given thread . If no such
 * timer exists yet , then it will be newly created .
 * @ param timerName
 * the name of the timer
 * @ param todoFlags
 * @ param threadId
 * of the thread to track , or 0 if only system clock should be
 * tracked
 * @ return timer */
public static ElkTimer getNamedTimer ( String timerName , int todoFlags , long threadId ) { } }

implementation:
ElkTimer key = new ElkTimer ( timerName , todoFlags , threadId ) ; ElkTimer previous = registeredTimers . putIfAbsent ( key , key ) ; if ( previous != null ) { return previous ; } // else
return key ;


signature:
public class ClassExpressionSaturationFactory { /** * Print statistics about the saturation */
public void printStatistics ( ) { } }

implementation: ruleApplicationFactory_ . getSaturationStatistics ( ) . print ( LOGGER_ ) ; if ( LOGGER_ . isDebugEnabled ( ) ) { if ( aggregatedStats_ . jobsSubmittedNo > 0 ) LOGGER_ . debug ( "Saturation Jobs Submitted=Done+Processed: {}={}+{}" , aggregatedStats_ . jobsSubmittedNo , aggregatedStats_ . jobsAlreadyDoneNo , aggregatedStats_ . jobsProcessedNo ) ; LOGGER_ . debug ( "Locks: " + aggregatedStats_ . locks ) ; }


signature:
public class ClassExpressionSaturationFactory { /** * waking up all workers waiting for new saturated contexts */
private void wakeUpWorkers ( ) { } }

implementation: if ( ! workersWaiting_ ) { return ; } stopWorkersLock_ . lock ( ) ; try { workersWaiting_ = false ; thereAreContextsToProcess_ . signalAll ( ) ; } finally { stopWorkersLock_ . unlock ( ) ; }


signature:
public class ClassExpressionSaturationFactory { /** * Updates the counter for processed contexts and jobs
 * @ param snapshotFinishedWorkers */
private void updateProcessedCounters ( int snapshotFinishedWorkers ) { } }

implementation:
if ( isInterrupted ( ) ) { wakeUpWorkers ( ) ; return ; } if ( countStartedWorkers_ . get ( ) > snapshotFinishedWorkers ) { /* * We are not the last worker processing the saturation state , so
 * the current jobs and contexts may not be processed yet . */
return ; } /* * Otherwise we were the last worker processing the saturation state ;
 * take the values for current jobs and contexts and verify that we are
 * still the last worker ( thus the order is important here ) . */
int snapshotCountJobsSubmitted = countJobsSubmittedUpper_ . get ( ) ; int snapshotCountContextNonSaturated = saturationState_ . getContextMarkNonSaturatedCount ( ) ; int snapshotCountStartedWorkers = countStartedWorkers_ . get ( ) ; if ( snapshotCountStartedWorkers > snapshotFinishedWorkers ) { /* no longer the last worker */
return ; } /* * If we arrive here , # snapshotCountJobsSubmitted and
 * # snapshotCountContextNonSaturated represents at least the number of
 * jobs processed and saturated contexts . Furthermore , since we took
 * them in this order , we know that all contexts for the processed jobs
 * were created , saturated , and counted . Now , we updated the
 * corresponding counters for the processed contexts and jobs but in the
 * reversed order to make sure that for every job considered to be
 * processed all contexts were already considered to be processed . */
if ( updateIfSmaller ( countContextsSaturatedLower_ , snapshotCountContextNonSaturated ) ) { /* * Sleeping workers can now take new inputs . */
wakeUpWorkers ( ) ; } updateIfSmaller ( countJobsProcessedLower_ , snapshotCountJobsSubmitted ) ;


signature:
public class ClassExpressionSaturationFactory { /** * Check if the counter for saturated contexts and processed jobs can be
 * increased and post - process the finished jobs
 * @ throws InterruptedException */
private void updateFinishedCounters ( ThisStatistics localStatistics ) throws InterruptedException { } }

implementation:
int snapshotJobsProcessed = countJobsProcessedLower_ . get ( ) ; /* * ensure that all contexts for processed jobs are marked as saturated */
for ( ; ; ) { int snapshotCountContextsSaturatedLower = countContextsSaturatedLower_ . get ( ) ; saturationState_ . setContextsSaturated ( snapshotCountContextsSaturatedLower ) ; if ( saturationState_ . getContextSetSaturatedCount ( ) < snapshotCountContextsSaturatedLower ) { /* * this means that some other worker also sets contexts as
 * saturated , then it will mark the finished jobs instead */
return ; } /* * ensure that the counter for processed jobs is still up to date */
int updatedSnapshotJobsProcessed = countJobsProcessedLower_ . get ( ) ; if ( updatedSnapshotJobsProcessed == snapshotJobsProcessed ) { break ; } /* else refresh counters */
snapshotJobsProcessed = updatedSnapshotJobsProcessed ; } /* * ensure that all processed jobs are finished */
for ( ; ; ) { int snapshotJobsFinished = countJobsFinishedUpper_ . get ( ) ; if ( snapshotJobsFinished >= snapshotJobsProcessed ) { break ; } /* * update the finished context counter at least to the taken
 * snapshot value and mark the corresponding number of jobs as
 * processed */
if ( ! countJobsFinishedUpper_ . compareAndSet ( snapshotJobsFinished , snapshotJobsFinished + 1 ) ) { /* retry */
continue ; } // else
J nextJob = jobsInProgress_ . poll ( ) ; IndexedContextRoot root = nextJob . getInput ( ) ; Context rootSaturation = saturationState_ . getContext ( root ) ; if ( rootSaturation . isInitialized ( ) && ! rootSaturation . isSaturated ( ) ) { LOGGER_ . error ( "{}: context for a finished job not saturated!" , rootSaturation ) ; } nextJob . setOutput ( rootSaturation ) ; LOGGER_ . trace ( "{}: saturation finished" , root ) ; localStatistics . jobsProcessedNo ++ ; listener_ . notifyFinished ( nextJob ) ; // can be interrupted
}


signature:
public class ClassExpressionSaturationFactory { /** * Update the counter to the value provided it is greater . Regardless of the
 * returned value , it is guaranteed that the value of the counter after
 * execution will be at least the input value .
 * @ param counter
 * the counter that should be updated
 * @ param value
 * the value to which the counter should be updated
 * @ return { @ code true } if the counter has been updated */
private static boolean updateIfSmaller ( AtomicInteger counter , int value ) { } }

implementation: for ( ; ; ) { int snapshotCoutner = counter . get ( ) ; if ( snapshotCoutner >= value ) return false ; if ( counter . compareAndSet ( snapshotCoutner , value ) ) return true ; }


signature:
public class BackwardLinkChainFromBackwardLinkRule { /** * Adds a { @ link BackwardLinkChainFromBackwardLinkRule } inferences for the
 * given { @ link ForwardLink } in the given { @ link Context }
 * @ param link
 * @ param context
 * @ return { @ code true } if the { @ link BackwardLinkChainFromBackwardLinkRule }
 * stored in the { @ link Context } is modified as a result of this
 * operation */
public static boolean addRuleFor ( ForwardLink link , Context context ) { } }

implementation: BackwardLinkChainFromBackwardLinkRule rule = context . getBackwardLinkRuleChain ( ) . getCreate ( MATCHER_ , FACTORY_ ) ; return rule . forwardLinksByObjectProperty_ . add ( link . getChain ( ) , link . getTarget ( ) ) ;


signature:
public class BackwardLinkChainFromBackwardLinkRule { /** * Removes a { @ link BackwardLinkChainFromBackwardLinkRule } inferences for
 * the given { @ link ForwardLink } from the given { @ link Context }
 * @ param link
 * @ param context
 * @ return { @ code true } if the { @ link BackwardLinkChainFromBackwardLinkRule }
 * stored in the { @ link Context } is modified as a result of this
 * operation */
public static boolean removeRuleFor ( ForwardLink link , Context context ) { } }

implementation: BackwardLinkChainFromBackwardLinkRule rule = context . getBackwardLinkRuleChain ( ) . find ( MATCHER_ ) ; return rule == null ? false : rule . forwardLinksByObjectProperty_ . remove ( link . getChain ( ) , link . getTarget ( ) ) ;


signature:
public class BackwardLinkChainFromBackwardLinkRule { /** * Tests if a { @ link BackwardLinkChainFromBackwardLinkRule } inferences for
 * the given { @ link ForwardLink } is present in the given { @ link Context }
 * @ param link
 * @ param context
 * @ return { @ code true } if the inference is present */
public static boolean containsRuleFor ( ForwardLink link , Context context ) { } }

implementation: BackwardLinkChainFromBackwardLinkRule rule = context . getBackwardLinkRuleChain ( ) . find ( MATCHER_ ) ; return rule == null ? false : rule . forwardLinksByObjectProperty_ . contains ( link . getChain ( ) , link . getTarget ( ) ) ;


signature:
public class DummyRuleVisitor { /** * The default implementation of all methods
 * @ param rule
 * @ param premise
 * @ param premises
 * @ param producer
 * @ return */
protected < P > O defaultVisit ( Rule < P > rule , P premise , ContextPremises premises , ClassInferenceProducer producer ) { } }

implementation: if ( LOGGER_ . isTraceEnabled ( ) ) { LOGGER_ . trace ( "ignore {} by {} in {}" , premise , rule , premises ) ; } return null ;


signature:
public class SubPropertyExplorer { /** * Computes all sub - { @ link IndexedPropertyChain } s of the given
 * { @ link IndexedPropertyChain } , if not computing before , recording all
 * { @ link ObjectPropertyInference } s using the provided { @ link Producer } . It
 * is ensured that all { @ link ObjectPropertyInference } s are applied only
 * once even if the method is called multiple times .
 * @ param input
 * the { @ link IndexedPropertyChain } for which to find the sub -
 * { @ link IndexedPropertyChain } s .
 * @ param inferenceProducer
 * the { @ link Producer } using which all applied
 * { @ link ObjectPropertyInference } s are recorded .
 * @ return the sub - { @ link IndexedPropertyChain } s of the given
 * { @ link IndexedPropertyChain } */
static Set < IndexedPropertyChain > getSubPropertyChains ( IndexedPropertyChain input , Producer < ? super SubPropertyChainInference > inferenceProducer , final PropertyHierarchyCompositionState . Dispatcher dispatcher ) { } }

implementation: return computeSubProperties ( input , inferenceProducer , dispatcher ) . getSubPropertyChains ( ) ;


signature:
public class SubPropertyExplorer { /** * Computes all sub - { @ link IndexedObjectProperty } s of the given
 * { @ link IndexedPropertyChain } , if not computing before , recording all
 * { @ link ObjectPropertyInference } s using the provided { @ link Producer } . It
 * is ensured that all { @ link ObjectPropertyInference } s are applied only
 * once even if the method is called multiple times .
 * @ param input
 * the { @ link IndexedPropertyChain } for which to find the sub -
 * { @ link IndexedObjectProperty } s .
 * @ param inferenceProducer
 * the { @ link Producer } using which all applied
 * { @ link ObjectPropertyInference } s are recorded .
 * @ return the sub - { @ link IndexedObjectProperty } of the given
 * { @ link IndexedPropertyChain } */
static Set < IndexedObjectProperty > getSubProperties ( IndexedPropertyChain input , Producer < ? super SubPropertyChainInference > inferenceProducer , final PropertyHierarchyCompositionState . Dispatcher dispatcher ) { } }

implementation: return computeSubProperties ( input , inferenceProducer , dispatcher ) . getSubProperties ( ) ;


signature:
public class SubPropertyExplorer { /** * Given an { @ link IndexedObjectProperty } Computes a { @ link Multimap } from
 * { @ link IndexedObjectProperty } s to { @ link IndexedObjectProperty }
 * consisting of the the assignments T - > S such that both S and
 * ObjectPropertyChain ( S , T ) are sub - properties of the given
 * { @ link IndexedObjectProperty } . The provided { @ link Producer } is used to
 * record all { @ link ObjectPropertyInference } s that are applied in this
 * computation of sub - { @ link IndexedPropertyChain } s involved . It is ensured
 * that the computation is performed only once .
 * @ param input
 * a given { @ link IndexedObjectProperty }
 * @ param inferenceProducer
 * @ return a multimap consisting of assignments T - > S such that both S and
 * ObjectPropertyChain ( S , T ) are sub - properties of the given
 * { @ link IndexedObjectProperty } */
static Multimap < IndexedObjectProperty , IndexedObjectProperty > getLeftSubComposableSubPropertiesByRightProperties ( IndexedObjectProperty input , Producer < ? super SubPropertyChainInference > inferenceProducer , final PropertyHierarchyCompositionState . Dispatcher dispatcher ) { } }

implementation:
SaturatedPropertyChain saturation = input . getSaturated ( ) ; if ( saturation . leftSubComposableSubPropertiesByRightPropertiesComputed ) return saturation . leftSubComposableSubPropertiesByRightProperties ; // else
synchronized ( saturation ) { if ( saturation . leftSubComposableSubPropertiesByRightProperties == null ) saturation . leftSubComposableSubPropertiesByRightProperties = new HashSetMultimap < IndexedObjectProperty , IndexedObjectProperty > ( ) ; } synchronized ( saturation . leftSubComposableSubPropertiesByRightProperties ) { if ( saturation . leftSubComposableSubPropertiesByRightPropertiesComputed ) return saturation . leftSubComposableSubPropertiesByRightProperties ; // else compute it
Set < IndexedObjectProperty > subProperties = getSubProperties ( input , inferenceProducer , dispatcher ) ; for ( IndexedPropertyChain subPropertyChain : getSubPropertyChains ( input , inferenceProducer , dispatcher ) ) { if ( subPropertyChain instanceof IndexedComplexPropertyChain ) { IndexedComplexPropertyChain composition = ( IndexedComplexPropertyChain ) subPropertyChain ; Set < IndexedObjectProperty > leftSubProperties = getSubProperties ( composition . getFirstProperty ( ) , inferenceProducer , dispatcher ) ; Set < IndexedObjectProperty > commonSubProperties = new LazySetIntersection < IndexedObjectProperty > ( subProperties , leftSubProperties ) ; if ( commonSubProperties . isEmpty ( ) ) continue ; // else
for ( IndexedObjectProperty rightSubProperty : getSubProperties ( composition . getSuffixChain ( ) , inferenceProducer , dispatcher ) ) for ( IndexedObjectProperty commonLeft : commonSubProperties ) saturation . leftSubComposableSubPropertiesByRightProperties . add ( rightSubProperty , commonLeft ) ; } } saturation . leftSubComposableSubPropertiesByRightPropertiesComputed = true ; } return saturation . leftSubComposableSubPropertiesByRightProperties ;


signature:
public class ObjectPropertyTaxonomyComputationFactory { /** * Adds the specified object property into the taxonomy if it is not in it
 * yet and sets its direct sub - properties if not set yet .
 * @ param property
 * The property that should be inserted into taxonomy . */
private void instertIntoTaxonomy ( final IndexedObjectProperty property ) { } }

implementation:
/* * @ formatter : off
 * Transitive reduction and taxonomy computation
 * if sub - properties of a sub - property contain this property ,
 * they are equivalent
 * if a property is a strict sub - property of another strict sub - property ,
 * it is not direct
 * @ formatter : on */
final Map < IndexedObjectProperty , ElkObjectProperty > equivalent = collectEquivalent ( property ) ; if ( equivalent == null ) { // Equivalent to top .
return ; } final Map < IndexedObjectProperty , Collection < ? extends ElkObjectProperty > > subEquivalent = new ArrayHashMap < IndexedObjectProperty , Collection < ? extends ElkObjectProperty > > ( ) ; final Set < IndexedObjectProperty > indirect = new ArrayHashSet < IndexedObjectProperty > ( ) ; for ( final IndexedObjectProperty subProperty : property . getSaturated ( ) . getSubProperties ( ) ) { if ( equivalent . containsKey ( subProperty ) ) { // subProperty is not strict
continue ; } // subProperty is strict
final Map < IndexedObjectProperty , ElkObjectProperty > subEq = collectEquivalent ( subProperty ) ; // should not be null , because top cannot be a strict sub - property
subEquivalent . put ( subProperty , subEq . values ( ) ) ; for ( final IndexedObjectProperty subSubProperty : subProperty . getSaturated ( ) . getSubProperties ( ) ) { if ( ! subEq . containsKey ( subSubProperty ) ) { // strict
indirect . add ( subSubProperty ) ; } } } /* * If property is not equivalent to bottom and there are no strict sub
 * properties , add the bottom as a default sub property . */
if ( subEquivalent . isEmpty ( ) && ( indexedBottomProperty_ == null || ! equivalent . containsKey ( indexedBottomProperty_ ) ) ) { outputProcessor_ . visit ( new TransitiveReductionOutputEquivalentDirectImpl < ElkObjectProperty > ( equivalent . values ( ) , defaultDirectSubproperties_ ) ) ; return ; } // else
final Collection < Collection < ? extends ElkObjectProperty > > direct = Operations . map ( subEquivalent . entrySet ( ) , new Operations . Transformation < Map . Entry < IndexedObjectProperty , Collection < ? extends ElkObjectProperty > > , Collection < ? extends ElkObjectProperty > > ( ) { @ Override public Collection < ? extends ElkObjectProperty > transform ( final Entry < IndexedObjectProperty , Collection < ? extends ElkObjectProperty > > element ) { if ( indirect . contains ( element . getKey ( ) ) ) { return null ; } else { return element . getValue ( ) ; } } } ) ; outputProcessor_ . visit ( new TransitiveReductionOutputEquivalentDirectImpl < ElkObjectProperty > ( equivalent . values ( ) , direct ) ) ;


signature:
public class ObjectPropertyTaxonomyComputationFactory { /** * Collects sub - properties of < code > property < / code > that are equivalent to
 * it . Returns < code > null < / code > if < code > property < / code > is equivalent to
 * the top property .
 * @ param property
 * @ return < code > null < / code > if the specified property is equivalent to the
 * top property , otherwise mapping from equivalent indexed
 * properties to their elk entities . */
private Map < IndexedObjectProperty , ElkObjectProperty > collectEquivalent ( final IndexedObjectProperty property ) { } }

implementation: final Set < IndexedObjectProperty > subProperties = property . getSaturated ( ) . getSubProperties ( ) ; final Map < IndexedObjectProperty , ElkObjectProperty > equivalent = new ArrayHashMap < IndexedObjectProperty , ElkObjectProperty > ( ) ; for ( final IndexedObjectProperty subProperty : subProperties ) { if ( subProperty . equals ( indexedTopProperty_ ) ) { outputProcessor_ . visit ( new TransitiveReductionOutputExtremeImpl < ElkObjectProperty > ( property . getElkEntity ( ) ) ) ; return null ; } if ( subProperty . getSaturated ( ) . getSubProperties ( ) . contains ( property ) || property . equals ( indexedBottomProperty_ ) ) { equivalent . put ( subProperty , subProperty . getElkEntity ( ) ) ; } } if ( indexedBottomProperty_ . getSaturated ( ) . getSubProperties ( ) . contains ( property ) ) { equivalent . put ( indexedBottomProperty_ , indexedBottomProperty_ . getElkEntity ( ) ) ; } return equivalent ;


signature:
public class AbstractReasonerState { /** * Flushes index , if needed , and completes loading if there is new input .
 * Incremental mode should be changed only during completing loading .
 * @ throws ElkException */
public synchronized void ensureLoading ( ) throws ElkException { } }

implementation:
if ( ! isLoadingFinished ( ) ) { if ( isIncrementalMode ( ) ) { if ( ! stageManager . incrementalAdditionStage . isCompleted ( ) ) { complete ( stageManager . incrementalAdditionStage ) ; } } else { if ( ! stageManager . contextInitializationStage . isCompleted ( ) ) { complete ( stageManager . contextInitializationStage ) ; } } LOGGER_ . trace ( "Reset axiom loading" ) ; stageManager . inputLoadingStage . invalidateRecursive ( ) ; // Invalidate stages at the beginnings of the dependency chains .
stageManager . contextInitializationStage . invalidateRecursive ( ) ; stageManager . incrementalCompletionStage . invalidateRecursive ( ) ; } complete ( stageManager . inputLoadingStage ) ;


signature:
public class AbstractReasonerState { /** * Ensures that saturation is restored and taxonomies are cleaned . Also
 * invalidates stages that depend on the saturation if it changed .
 * @ throws ElkException */
private void restoreSaturation ( ) throws ElkException { } }

implementation: ensureLoading ( ) ; final boolean changed ; if ( isIncrementalMode ( ) ) { changed = ! stageManager . incrementalTaxonomyCleaningStage . isCompleted ( ) ; complete ( stageManager . incrementalTaxonomyCleaningStage ) ; } else { changed = ! stageManager . contextInitializationStage . isCompleted ( ) ; complete ( stageManager . contextInitializationStage ) ; } if ( changed ) { stageManager . consistencyCheckingStage . invalidateRecursive ( ) ; }


signature:
public class AbstractReasonerState { /** * Check consistency of the current ontology , if this has not been done yet .
 * @ return { @ code true } if the ontology is inconsistent , that is ,
 * unsatisfiable .
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
public synchronized boolean isInconsistent ( ) throws ElkException { } }

implementation: restoreConsistencyCheck ( ) ; if ( ! consistencyCheckingState . isInconsistent ( ) ) { incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassification ( ) ) ; } return consistencyCheckingState . isInconsistent ( ) ;


signature:
public class AbstractReasonerState { /** * Complete the taxonomy computation stage and the stages it depends on , if
 * it has not been done yet .
 * @ return the class taxonomy implied by the current ontology
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
protected Taxonomy < ElkClass > restoreTaxonomy ( ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
ruleAndConclusionStats . reset ( ) ; // also restores saturation and cleans the taxonomy if necessary
restoreConsistencyCheck ( ) ; if ( consistencyCheckingState . isInconsistent ( ) ) { throw new ElkInconsistentOntologyException ( ) ; } complete ( stageManager . classTaxonomyComputationStage ) ; return classTaxonomyState . getTaxonomy ( ) ;


signature:
public class AbstractReasonerState { /** * Compute the inferred taxonomy of the named classes for the given ontology
 * if it has not been done yet .
 * @ return the class taxonomy implied by the current ontology
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
public synchronized Taxonomy < ElkClass > getTaxonomy ( ) throws ElkInconsistentOntologyException , ElkException { } }

implementation: restoreTaxonomy ( ) ; incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassification ( ) ) ; return classTaxonomyState . getTaxonomy ( ) ;


signature:
public class AbstractReasonerState { /** * Compute the inferred taxonomy of the named classes for the given ontology
 * if it has not been done yet .
 * @ return the class taxonomy implied by the current ontology
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
public synchronized Taxonomy < ElkClass > getTaxonomyQuietly ( ) throws ElkException { } }

implementation: Taxonomy < ElkClass > result ; try { result = getTaxonomy ( ) ; } catch ( ElkInconsistentOntologyException e ) { LOGGER_ . debug ( "Ontology is inconsistent" ) ; result = new SingletoneTaxonomy < ElkClass , OrphanTaxonomyNode < ElkClass > > ( ElkClassKeyProvider . INSTANCE , getAllClasses ( ) , new TaxonomyNodeFactory < ElkClass , OrphanTaxonomyNode < ElkClass > , Taxonomy < ElkClass > > ( ) { @ Override public OrphanTaxonomyNode < ElkClass > createNode ( final Iterable < ? extends ElkClass > members , final int size , final Taxonomy < ElkClass > taxonomy ) { return new OrphanTaxonomyNode < ElkClass > ( members , size , elkFactory_ . getOwlNothing ( ) , taxonomy ) ; } } ) ; } return result ;


signature:
public class AbstractReasonerState { /** * Completes instance taxonomy computation stage and the stages that it
 * depends on , if this has not been done yet .
 * @ return the instance taxonomy implied by the current ontology
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
protected InstanceTaxonomy < ElkClass , ElkNamedIndividual > restoreInstanceTaxonomy ( ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
ruleAndConclusionStats . reset ( ) ; // also restores saturation and cleans the taxonomy if necessary
restoreConsistencyCheck ( ) ; if ( consistencyCheckingState . isInconsistent ( ) ) { throw new ElkInconsistentOntologyException ( ) ; } complete ( stageManager . instanceTaxonomyComputationStage ) ; return instanceTaxonomyState . getTaxonomy ( ) ;


signature:
public class AbstractReasonerState { /** * Compute the inferred taxonomy of the named classes with instances if this
 * has not been done yet .
 * @ return the instance taxonomy implied by the current ontology
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
public synchronized InstanceTaxonomy < ElkClass , ElkNamedIndividual > getInstanceTaxonomy ( ) throws ElkInconsistentOntologyException , ElkException { } }

implementation: restoreInstanceTaxonomy ( ) ; incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassification ( ) ) ; return instanceTaxonomyState . getTaxonomy ( ) ;


signature:
public class AbstractReasonerState { /** * Compute the inferred taxonomy of the named classes with instances if this
 * has not been done yet .
 * @ return the instance taxonomy implied by the current ontology
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
public synchronized InstanceTaxonomy < ElkClass , ElkNamedIndividual > getInstanceTaxonomyQuietly ( ) throws ElkException { } }

implementation:
InstanceTaxonomy < ElkClass , ElkNamedIndividual > result ; try { result = getInstanceTaxonomy ( ) ; } catch ( ElkInconsistentOntologyException e ) { LOGGER_ . debug ( "Ontology is inconsistent" ) ; result = new SingletoneInstanceTaxonomy < ElkClass , ElkNamedIndividual , OrphanTypeNode < ElkClass , ElkNamedIndividual > > ( ElkClassKeyProvider . INSTANCE , getAllClasses ( ) , new TaxonomyNodeFactory < ElkClass , OrphanTypeNode < ElkClass , ElkNamedIndividual > , Taxonomy < ElkClass > > ( ) { @ Override public OrphanTypeNode < ElkClass , ElkNamedIndividual > createNode ( final Iterable < ? extends ElkClass > members , final int size , final Taxonomy < ElkClass > taxonomy ) { final OrphanTypeNode < ElkClass , ElkNamedIndividual > node = new OrphanTypeNode < ElkClass , ElkNamedIndividual > ( members , size , elkFactory_ . getOwlNothing ( ) , taxonomy , 1 ) ; final Set < ElkNamedIndividual > allNamedIndividuals = getAllNamedIndividuals ( ) ; final Iterator < ElkNamedIndividual > namedIndividualIterator = allNamedIndividuals . iterator ( ) ; if ( namedIndividualIterator . hasNext ( ) ) { // there is at least one individual
node . addInstanceNode ( new OrphanInstanceNode < ElkClass , ElkNamedIndividual > ( allNamedIndividuals , allNamedIndividuals . size ( ) , namedIndividualIterator . next ( ) , ElkIndividualKeyProvider . INSTANCE , node ) ) ; } return node ; } } , ElkIndividualKeyProvider . INSTANCE ) ; } return result ;


signature:
public class AbstractReasonerState { /** * Compute the inferred taxonomy of the object properties for the given
 * ontology if it has not been done yet .
 * @ return the object property taxonomy implied by the current ontology
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
public synchronized Taxonomy < ElkObjectProperty > getObjectPropertyTaxonomy ( ) throws ElkInconsistentOntologyException , ElkException { } }

implementation: ruleAndConclusionStats . reset ( ) ; restoreConsistencyCheck ( ) ; if ( consistencyCheckingState . isInconsistent ( ) ) { throw new ElkInconsistentOntologyException ( ) ; } LOGGER_ . trace ( "Property hierarchy computation" ) ; complete ( stageManager . objectPropertyTaxonomyComputationStage ) ; incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassification ( ) ) ; return objectPropertyTaxonomyState . getTaxonomy ( ) ;


signature:
public class AbstractReasonerState { /** * Compute the inferred taxonomy of the object properties for the given
 * ontology if it has not been done yet .
 * @ return the object property taxonomy implied by the current ontology
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
public synchronized Taxonomy < ElkObjectProperty > getObjectPropertyTaxonomyQuietly ( ) throws ElkException { } }

implementation: Taxonomy < ElkObjectProperty > result ; try { result = getObjectPropertyTaxonomy ( ) ; } catch ( ElkInconsistentOntologyException e ) { LOGGER_ . debug ( "Ontology is inconsistent" ) ; result = new SingletoneTaxonomy < ElkObjectProperty , OrphanTaxonomyNode < ElkObjectProperty > > ( ElkObjectPropertyKeyProvider . INSTANCE , getAllObjectProperties ( ) , new TaxonomyNodeFactory < ElkObjectProperty , OrphanTaxonomyNode < ElkObjectProperty > , Taxonomy < ElkObjectProperty > > ( ) { @ Override public OrphanTaxonomyNode < ElkObjectProperty > createNode ( final Iterable < ? extends ElkObjectProperty > members , final int size , final Taxonomy < ElkObjectProperty > taxonomy ) { return new OrphanTaxonomyNode < ElkObjectProperty > ( members , size , elkFactory_ . getOwlBottomObjectProperty ( ) , taxonomy ) ; } } ) ; } return result ;


signature:
public class AbstractReasonerState { /** * If the query results are not cached yet , indexes the supplied class
 * expression and , if successful , computes the query so that the results for
 * this expressions are ready in { @ link # classExpressionQueryState _ } .
 * @ param classExpression
 * @ param computeInstanceTaxonomy
 * if { @ code false } , only class taxonomy is computed , if
 * { @ code true } , also instance taxonomy is computed .
 * @ return < code > true < / code > if the query was indexed successfully ,
 * < code > false < / code > otherwise , i . e . , when the class expression is
 * not supported
 * @ throws ElkInconsistentOntologyException
 * @ throws ElkException */
private boolean computeQuery ( final ElkClassExpression classExpression , final boolean computeInstanceTaxonomy ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
// Load the query
classExpressionQueryState_ . registerQuery ( classExpression ) ; ensureLoading ( ) ; // Complete all stages
if ( computeInstanceTaxonomy ) { restoreInstanceTaxonomy ( ) ; } else { restoreTaxonomy ( ) ; } if ( ! classExpressionQueryState_ . isIndexed ( classExpression ) ) { return false ; } /* * If query result is cashed , but there were some changes to the
 * ontology , it may not be up to date . Whether it is is checked during
 * stages that clean contexts . These are run , if necessary , by the call
 * above . */
if ( classExpressionQueryState_ . isComputed ( classExpression ) ) { return true ; } stageManager . classExpressionQueryStage . invalidateRecursive ( ) ; try { complete ( stageManager . classExpressionQueryStage ) ; } catch ( final ElkInterruptedException e ) { if ( classExpressionQueryState_ . isComputed ( classExpression ) ) { /* * If the stage was interrupted , but the query is already
 * computed , completing the stage will not be attempted during
 * the next call . We need to call postExecute ( ) manually , so
 * that the stage wouldn ' t stay initialized with computation
 * that already processed all its inputs ( or at least the
 * queried class ) . */
stageManager . classExpressionQueryStage . postExecute ( ) ; } else { throw e ; } } return true ;


signature:
public class AbstractReasonerState { /** * Decides whether the supplied ( possibly complex ) class expression is
 * satisfiable . The query state is updated accordingly .
 * @ param classExpression
 * The queried class expression .
 * @ return whether the supplied class expression is satisfiable .
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
protected boolean querySatisfiability ( final ElkClassExpression classExpression ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
final boolean result ; if ( computeQuery ( classExpression , false ) ) { result = classExpressionQueryState_ . isSatisfiable ( classExpression ) ; } else { // classExpression couldn ' t be indexed ; pretend it is a fresh class
result = true ; } // If classExpression is unsatisfiable , the result is complete .
if ( result ) { incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassExpressionQuery ( classExpressionQueryState_ . getOccurrenceStore ( classExpression ) ) ) ; } return result ;


signature:
public class AbstractReasonerState { /** * Computes all atomic classes that are equivalent to the supplied ( possibly
 * complex ) class expression . The query state is updated accordingly .
 * @ param classExpression
 * The queried class expression .
 * @ return all atomic classes that are equivalent to the supplied class
 * expression .
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
protected Node < ElkClass > queryEquivalentClasses ( final ElkClassExpression classExpression ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
final Node < ElkClass > result ; if ( computeQuery ( classExpression , false ) ) { final Node < ElkClass > r = classExpressionQueryState_ . getEquivalentClasses ( classExpression ) ; if ( r == null ) { result = classTaxonomyState . getTaxonomy ( ) . getBottomNode ( ) ; } else { result = r ; } } else { // classExpression couldn ' t be indexed ; pretend it is a fresh class
result = new QueryNode < ElkClass > ( ElkClassKeyProvider . INSTANCE ) ; } incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassExpressionQuery ( classExpressionQueryState_ . getOccurrenceStore ( classExpression ) ) ) ; return result ;


signature:
public class AbstractReasonerState { /** * Computes all atomic direct super - classes of the supplied ( possibly
 * complex ) class expression . The query state is updated accordingly .
 * @ param classExpression
 * The queried class expression .
 * @ return all atomic direct super - classes of the supplied class expression .
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
protected Set < ? extends Node < ElkClass > > queryDirectSuperClasses ( final ElkClassExpression classExpression ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
final Set < ? extends Node < ElkClass > > result ; if ( computeQuery ( classExpression , false ) ) { final Set < ? extends Node < ElkClass > > r = classExpressionQueryState_ . getDirectSuperClasses ( classExpression ) ; if ( r == null ) { result = classTaxonomyState . getTaxonomy ( ) . getBottomNode ( ) . getDirectSuperNodes ( ) ; } else { result = r ; } } else { // classExpression couldn ' t be indexed ; pretend it is a fresh class
result = Collections . singleton ( classTaxonomyState . getTaxonomy ( ) . getTopNode ( ) ) ; } incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassExpressionQuery ( classExpressionQueryState_ . getOccurrenceStore ( classExpression ) ) ) ; return result ;


signature:
public class AbstractReasonerState { /** * Computes all atomic direct sub - classes of the supplied ( possibly complex )
 * class expression . The query state is updated accordingly .
 * @ param classExpression
 * The queried class expression .
 * @ return all atomic direct sub - classes of the supplied class expression .
 * @ throws ElkInconsistentOntologyException
 * if the ontology is inconsistent
 * @ throws ElkException
 * if the reasoning process cannot be completed successfully */
protected Set < ? extends Node < ElkClass > > queryDirectSubClasses ( final ElkClassExpression classExpression ) throws ElkInconsistentOntologyException , ElkException { } }

implementation:
final Set < ? extends Node < ElkClass > > result ; if ( computeQuery ( classExpression , false ) ) { final Taxonomy < ElkClass > taxonomy = classTaxonomyState . getTaxonomy ( ) ; final Set < ? extends Node < ElkClass > > r = classExpressionQueryState_ . getDirectSubClasses ( classExpression , taxonomy ) ; if ( r == null ) { result = taxonomy . getBottomNode ( ) . getDirectSubNodes ( ) ; } else { result = r ; } } else { // classExpression couldn ' t be indexed ; pretend it is a fresh class
result = Collections . singleton ( classTaxonomyState . getTaxonomy ( ) . getBottomNode ( ) ) ; } incompleteness_ . log ( incompleteness_ . getIncompletenessMonitorForClassExpressionQuery ( classExpressionQueryState_ . getOccurrenceStore ( classExpression ) ) ) ; return result ;