org.omnaest.i18nbinder.grouping
Class FileGrouper

java.lang.Object
  extended by org.omnaest.i18nbinder.grouping.FileGrouper

public class FileGrouper
extends Object

This class supports the grouping of File instances by their file names.

The grouping is tried to be done to as many defined regular expression groups as possible. This implies the groups have the same value. If the values are different only the first group is replaced.

Author:
Omnaest
See Also:
#determineFileGroupList()

Field Summary
protected  List<File> fileList
           
protected  String GROUPING_REPLACEMENT_TOKEN_DEFAULT
           
protected  Pattern groupingPattern
           
protected  List<Integer> groupingPatternGroupingGroupIndexList
           
protected  String groupingPatternReplacementToken
           
 
Constructor Summary
FileGrouper()
           
 
Method Summary
 boolean addAllFiles(Collection<? extends File> fileCollection)
          Adds all given File instances to the FileGrouper.
 boolean addFile(File e)
          Adds the given File to the FileGrouper.
 void clearFiles()
          Clears the Files from the FileGrouper.
 boolean containsFile(File file)
           
 Map<String,FileGroup> determineFileGroupIdentifierToFileGroupMap()
          Determines a Map with the file group identifier as key and the FileGroup instances as values.
 List<Integer> getGroupingPatternGroupingGroupIndexList()
           
 String getGroupingPatternReplacementToken()
           
 String getGroupingPatternString()
           
 boolean remove(File file)
          Removes the given File from the FileGrouper.
 boolean removeAll(Collection<File> fileCollection)
          Removes all given File instances from the FileGrouper.
 void setGroupingPatternGroupingGroupIndexList(List<Integer> groupingPatternGroupingGroupIndexList)
           
 void setGroupingPatternReplacementToken(String groupingPatternReplacementToken)
           
 void setGroupingPatternString(String groupingPatternString)
           
 int size()
          Returns the number of files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUPING_REPLACEMENT_TOKEN_DEFAULT

protected String GROUPING_REPLACEMENT_TOKEN_DEFAULT

fileList

protected List<File> fileList

groupingPattern

protected Pattern groupingPattern

groupingPatternGroupingGroupIndexList

protected List<Integer> groupingPatternGroupingGroupIndexList

groupingPatternReplacementToken

protected String groupingPatternReplacementToken
Constructor Detail

FileGrouper

public FileGrouper()
Method Detail

determineFileGroupIdentifierToFileGroupMap

public Map<String,FileGroup> determineFileGroupIdentifierToFileGroupMap()
Determines a Map with the file group identifier as key and the FileGroup instances as values. This grouping is based on an investigation in the absolute file names. If they match the given grouping pattern the first group of the pattern is replaced by an general token. If the resulting string from multiple files match now, they are grouped together.

For example the files and the grouping pattern ".*?_(\\w{2,3}_\\w{2,3}|\\w{2,3})\\.\\w*" will result in a group called "admin_{group}.properties" which holds references to these two files.

See Also:
setGroupingPatternString(String), FileGroup

addFile

public boolean addFile(File e)
Adds the given File to the FileGrouper.

Parameters:
e -
Returns:

addAllFiles

public boolean addAllFiles(Collection<? extends File> fileCollection)
Adds all given File instances to the FileGrouper.

Parameters:
fileCollection -
Returns:

clearFiles

public void clearFiles()
Clears the Files from the FileGrouper.


containsFile

public boolean containsFile(File file)

remove

public boolean remove(File file)
Removes the given File from the FileGrouper.

Parameters:
file -
Returns:

removeAll

public boolean removeAll(Collection<File> fileCollection)
Removes all given File instances from the FileGrouper.

Parameters:
fileCollection -
Returns:

size

public int size()
Returns the number of files.

Returns:

getGroupingPatternString

public String getGroupingPatternString()

setGroupingPatternString

public void setGroupingPatternString(String groupingPatternString)
                              throws Exception
Throws:
Exception

getGroupingPatternReplacementToken

public String getGroupingPatternReplacementToken()

setGroupingPatternReplacementToken

public void setGroupingPatternReplacementToken(String groupingPatternReplacementToken)

getGroupingPatternGroupingGroupIndexList

public List<Integer> getGroupingPatternGroupingGroupIndexList()

setGroupingPatternGroupingGroupIndexList

public void setGroupingPatternGroupingGroupIndexList(List<Integer> groupingPatternGroupingGroupIndexList)


Copyright © 2012. All Rights Reserved.