Package org.pentaho.di.ui.i18n
Class MessagesSourceCrawler
- java.lang.Object
-
- org.pentaho.di.ui.i18n.MessagesSourceCrawler
-
public class MessagesSourceCrawler extends Object
This class takes care of crawling through the source code- Author:
- matt
-
-
Constructor Summary
Constructors Constructor Description MessagesSourceCrawler(org.pentaho.di.core.logging.LogChannelInterface log, List<String> sourceDirectories, String singleMessagesFile, List<SourceCrawlerXMLFolder> xmlFolders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addKeyOccurrence(KeyOccurrence occ)
Add a key occurrence to the list of occurrences.void
crawl()
void
crawlSourceDirectories()
protected void
crawlXmlFolders()
protected String
getCompleteLine(BufferedReader reader, String line, List<String> splitLinePhrases)
List<String>
getFilesToAvoid()
KeyOccurrence
getKeyOccurrence(String key, String selectedMessagesPackage)
List<KeyOccurrence>
getKeyOccurrences(String sourceFolder)
Get the unique package-keyList<String>
getMessagesPackagesList(String sourceFolder)
List<KeyOccurrence>
getOccurrencesForPackage(String messagesPackage)
Get all the key occurrences for a certain messages package.String[]
getScanPhrases()
String
getSingleMessagesFile()
List<String>
getSourceDirectories()
Map<String,Map<String,List<KeyOccurrence>>>
getSourcePackageOccurrences()
protected List<String>
getSplitLinePhrases(String scanPhrase)
Returns all regex expressions to detect when the given scanPhrase is incomplete (existing over more than one source line).protected String
getWhitespacesSanitizeRegex(String str)
Calculates a regex to identify the given text considering all possibleSPLIT_CHARACTERS
can be surrounded by whitespaces.void
lookForOccurrencesInFile(String sourceFolder, org.apache.commons.vfs2.FileObject javaFile)
Look for occurrences of keys in the specified file.protected void
lookForOccurrencesInLine(String sourceFolder, org.apache.commons.vfs2.FileObject javaFile, String messagesPackage, int row, String line)
Look for occurrences of keys in the specified line.void
setFilesToAvoid(List<String> filesToAvoid)
void
setScanPhrases(String[] scanPhrases)
void
setSingleMessagesFile(String singleMessagesFile)
void
setSourceDirectories(List<String> sourceDirectories)
void
setSourcePackageOccurrences(Map<String,Map<String,List<KeyOccurrence>>> sourcePackageOccurrences)
-
-
-
Constructor Detail
-
MessagesSourceCrawler
public MessagesSourceCrawler(org.pentaho.di.core.logging.LogChannelInterface log, List<String> sourceDirectories, String singleMessagesFile, List<SourceCrawlerXMLFolder> xmlFolders)
- Parameters:
sourceDirectories
- The source directories to crawl throughsingleMessagesFile
- the messages file if there is only one, otherwise: null
-
-
Method Detail
-
addKeyOccurrence
public void addKeyOccurrence(KeyOccurrence occ)
Add a key occurrence to the list of occurrences. The list is kept sorted on key and message package. If the key already exists, we increment the number of occurrences.- Parameters:
occ
- The key occurrence to add
-
lookForOccurrencesInFile
public void lookForOccurrencesInFile(String sourceFolder, org.apache.commons.vfs2.FileObject javaFile) throws IOException
Look for occurrences of keys in the specified file.- Parameters:
sourceFolder
- The folder the java file and messages files live injavaFile
- The java source file to examine- Throws:
IOException
- In case there is a problem accessing the specified source file.
-
getCompleteLine
protected String getCompleteLine(BufferedReader reader, String line, List<String> splitLinePhrases) throws IOException
- Throws:
IOException
-
lookForOccurrencesInLine
protected void lookForOccurrencesInLine(String sourceFolder, org.apache.commons.vfs2.FileObject javaFile, String messagesPackage, int row, String line)
Look for occurrences of keys in the specified line.- Parameters:
sourceFolder
- the folder where the file that contains the line to examine existsjavaFile
- the java source file that contains the line to examinemessagesPackage
- the message package usedrow
- the row numberline
- the line to examine
-
getSplitLinePhrases
protected List<String> getSplitLinePhrases(String scanPhrase)
Returns all regex expressions to detect when the given scanPhrase is incomplete (existing over more than one source line).
- Parameters:
scanPhrase
- the scanPhrase to consider- Returns:
- all regex expressions to detect when the given scanPhrase is incomplete
- See Also:
getSplitLinePhrases(String[])
-
getWhitespacesSanitizeRegex
protected String getWhitespacesSanitizeRegex(String str)
Calculates a regex to identify the given text considering all possible
SPLIT_CHARACTERS
can be surrounded by whitespaces.- Parameters:
str
- the text to be used- Returns:
- regex to identify the given text considering all possible
SPLIT_CHARACTERS
can be surrounded by whitespaces
-
getMessagesPackagesList
public List<String> getMessagesPackagesList(String sourceFolder)
- Returns:
- A sorted
List
of distinct occurrences of the used message package names
-
getOccurrencesForPackage
public List<KeyOccurrence> getOccurrencesForPackage(String messagesPackage)
Get all the key occurrences for a certain messages package.- Parameters:
messagesPackage
- the package to hunt for- Returns:
- all the key occurrences for a certain messages package.
-
getKeyOccurrence
public KeyOccurrence getKeyOccurrence(String key, String selectedMessagesPackage)
-
getKeyOccurrences
public List<KeyOccurrence> getKeyOccurrences(String sourceFolder)
Get the unique package-key- Parameters:
sourceFolder
-
-
getSourceDirectories
public List<String> getSourceDirectories()
- Returns:
- the
List
of source directories to crawl through
-
setSourceDirectories
public void setSourceDirectories(List<String> sourceDirectories)
- Parameters:
sourceDirectories
- theList
of source directories to crawl through
-
setFilesToAvoid
public void setFilesToAvoid(List<String> filesToAvoid)
- Parameters:
filesToAvoid
- theList
of files to avoid
-
getSingleMessagesFile
public String getSingleMessagesFile()
- Returns:
- the singleMessagesFile
-
setSingleMessagesFile
public void setSingleMessagesFile(String singleMessagesFile)
- Parameters:
singleMessagesFile
- the singleMessagesFile to set
-
getScanPhrases
public String[] getScanPhrases()
- Returns:
- the scanPhrases to search for
-
setScanPhrases
public void setScanPhrases(String[] scanPhrases)
- Parameters:
scanPhrases
- the scanPhrases to search for
-
getSourcePackageOccurrences
public Map<String,Map<String,List<KeyOccurrence>>> getSourcePackageOccurrences()
- Returns:
- the sourcePackageOccurrences
-
-