question: protected void initializePatterns ( ) { customLevelsParser = new CustomLevelsParser ( customLevelDefinitions ) ; List < String > buildingKeywords = new ArrayList < > ( ) ; String newPattern = logFormat ; int index = 0 ; String current = newPattern ; List < String > propertyNames = new ArrayList < > ( ) ; while ( index > - 1 ) { if ( current . contains ( PROP_START ) && current . indexOf ( PROP_END ) > - 1 ) { index = current . indexOf ( PROP_START ) ; String longPropertyName = current . substring ( current . indexOf ( PROP_START ) , current . indexOf ( PROP_END ) + 1 ) ; String shortProp = getShortPropertyName ( longPropertyName ) ; buildingKeywords . add ( shortProp ) ; propertyNames . add ( longPropertyName ) ; current = current . substring ( longPropertyName . length ( ) + 1 + index ) ; newPattern = singleReplace ( newPattern , longPropertyName , Integer . toString ( buildingKeywords . size ( ) - 1 ) ) ; } else { index = - 1 ; } } Iterator iter = keywords . iterator ( ) ; while ( iter . hasNext ( ) ) { String keyword = ( String ) iter . next ( ) ; int index2 = newPattern . indexOf ( keyword ) ; if ( index2 > - 1 ) { buildingKeywords . add ( keyword ) ; newPattern = singleReplace ( newPattern , keyword , Integer . toString ( buildingKeywords . size ( ) - 1 ) ) ; } } String buildingInt = "" ; for ( int i = 0 ; i < newPattern . length ( ) ; i ++ ) { String thisValue = String . valueOf ( newPattern . substring ( i , i + 1 ) ) ; if ( isInteger ( thisValue ) ) { buildingInt = buildingInt + thisValue ; } else { if ( isInteger ( buildingInt ) ) { matchingKeywords . add ( buildingKeywords . get ( Integer . parseInt ( buildingInt ) ) ) ; } buildingInt = "" ; } } if ( isInteger ( buildingInt ) ) { matchingKeywords . add ( buildingKeywords . get ( Integer . parseInt ( buildingInt ) ) ) ; } newPattern = replaceMetaChars ( newPattern ) ; newPattern = newPattern . replaceAll ( MULTIPLE_SPACES_REGEXP , MULTIPLE_SPACES_REGEXP ) ; newPattern = newPattern . replaceAll ( Pattern . quote ( PATTERN_WILDCARD ) , REGEXP_DEFAULT_WILDCARD ) ; for ( int i = 0 ; i < buildingKeywords . size ( ) ; i ++ ) { String keyword = buildingKeywords . get ( i ) ; if ( i == ( buildingKeywords . size ( ) - 1 ) ) { newPattern = singleReplace ( newPattern , String . valueOf ( i ) , GREEDY_GROUP ) ; } else if ( TIMESTAMP . equals ( keyword ) ) { newPattern = singleReplace ( newPattern , String . valueOf ( i ) , "(" + timestampPatternText . replaceAll ( "'" , "" ) + ")" ) ; } else if ( LOGGER . equals ( keyword ) || LEVEL . equals ( keyword ) ) { newPattern = singleReplace ( newPattern , String . valueOf ( i ) , NOSPACE_GROUP ) ; } else { newPattern = singleReplace ( newPattern , String . valueOf ( i ) , DEFAULT_GROUP ) ; } } regexp = newPattern ; LOG . fine ( "regexp is " + regexp ) ; }
target:  Build the regular expression needed to parse log entries