void processSiteRow ( String siteRow ) { String [ ] row = getSiteRowFields ( siteRow ) ; String filePath = "" ; String pagePath = "" ; String dataArray = row [ 8 ] . substring ( row [ 8 ] . indexOf ( ' ' ) , row [ 8 ] . length ( ) - 2 ) ; // Explanation for the regular expression below: // "'{' or ';'" followed by either // "NOT: ';', '{', or '}'" repeated one or more times; or // "a single '}'" // The first case matches ";s:5:\"paths\"" // but also ";a:2:" in "{s:5:\"paths\";a:2:{s:9:\ ...". // The second case matches ";}" which terminates (sub)arrays. Matcher matcher = Pattern . compile ( "[{;](([^;}{][^;}{]*)|[}])" ) . matcher ( dataArray ) ; String prevString = "" ; String curString = "" ; String path = "" ; boolean valuePosition = false ; while ( matcher . find ( ) ) { String match = matcher . group ( ) . substring ( 1 ) ; if ( match . length ( ) == 0 ) { valuePosition = false ; continue ; } if ( match . charAt ( 0 ) == ' ' ) { valuePosition = ! valuePosition && ! "" . equals ( prevString ) ; curString = match . substring ( match . indexOf ( ' ' ) + 1 , match . length ( ) - 2 ) ; } else if ( match . charAt ( 0 ) == ' ' ) { valuePosition = false ; path = path + "/" + prevString ; } else if ( "}" . equals ( match ) ) { valuePosition = false ; path = path . substring ( 0 , path . lastIndexOf ( ' ' ) ) ; } if ( valuePosition && "file_path" . equals ( prevString ) && "/paths" . equals ( path ) ) { filePath = curString ; } else if ( valuePosition && "page_path" . equals ( prevString ) && "/paths" . equals ( path ) ) { pagePath = curString ; } prevString = curString ; curString = "" ; } MwSitesDumpFileProcessor . logger . debug ( "Found site data \"" + row [ 1 ] + "\" (group \"" + row [ 3 ] + "\", language \"" + row [ 5 ] + "\", type \"" + row [ 2 ] + "\")" ) ; this . sites . setSiteInformation ( row [ 1 ] , row [ 3 ] , row [ 5 ] , row [ 2 ] , filePath , pagePath ) ; }
Processes a row of the sites table and stores the site information found therein .