Package org.pentaho.di.ui.i18n
Class MessagesSourceCrawler
java.lang.Object
org.pentaho.di.ui.i18n.MessagesSourceCrawler
This class takes care of crawling through the source code
- Author:
- matt
-
Constructor Summary
ConstructorDescriptionMessagesSourceCrawler
(org.pentaho.di.core.logging.LogChannelInterface log, List<String> sourceDirectories, String singleMessagesFile, List<SourceCrawlerXMLFolder> xmlFolders) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a key occurrence to the list of occurrences.void
crawl()
void
protected void
protected String
getCompleteLine
(BufferedReader reader, String line, List<String> splitLinePhrases) getKeyOccurrence
(String key, String selectedMessagesPackage) getKeyOccurrences
(String sourceFolder) Get the unique package-keygetMessagesPackagesList
(String sourceFolder) getOccurrencesForPackage
(String messagesPackage) Get all the key occurrences for a certain messages package.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
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 Details
-
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 Details
-
addKeyOccurrence
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
-
crawl
- Throws:
Exception
-
crawlSourceDirectories
- Throws:
Exception
-
crawlXmlFolders
- Throws:
Exception
-
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
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
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
- Returns:
- A sorted
List
of distinct occurrences of the used message package names
-
getOccurrencesForPackage
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
-
getKeyOccurrences
Get the unique package-key- Parameters:
sourceFolder
-
-
getSourceDirectories
- Returns:
- the
List
of source directories to crawl through
-
setSourceDirectories
- Parameters:
sourceDirectories
- theList
of source directories to crawl through
-
getFilesToAvoid
- Returns:
- the
List
of files to avoid
-
setFilesToAvoid
- Parameters:
filesToAvoid
- theList
of files to avoid
-
getSingleMessagesFile
- Returns:
- the singleMessagesFile
-
setSingleMessagesFile
- Parameters:
singleMessagesFile
- the singleMessagesFile to set
-
getScanPhrases
- Returns:
- the scanPhrases to search for
-
setScanPhrases
- Parameters:
scanPhrases
- the scanPhrases to search for
-
getSourcePackageOccurrences
- Returns:
- the sourcePackageOccurrences
-
setSourcePackageOccurrences
public void setSourcePackageOccurrences(Map<String, Map<String, List<KeyOccurrence>>> sourcePackageOccurrences) - Parameters:
sourcePackageOccurrences
- the sourcePackageOccurrences to set
-