Package org.corpus_tools.pepper.common
Class PepperUtil
- java.lang.Object
-
- org.corpus_tools.pepper.common.PepperUtil
-
public abstract class PepperUtil extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPepperUtil.PepperJobReporterPrints the status of the passedPepperJobobject, until {@link #setStop(Boolean#TRUE)} was called.
-
Field Summary
Fields Modifier and Type Field Description static intCONSOLE_WIDTHThe standard width of the output console of Pepper.static intCONSOLE_WIDTH_120The width of the output console of Pepper.static intCONSOLE_WIDTH_80The width of the output console of Pepper, when os is windows.static StringFILE_ENDING_PEPPERThis is the default ending of a Pepper workflow description file.
-
Constructor Summary
Constructors Constructor Description PepperUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringbreakString(String theString)Breaks the StringtheStringat positionCONSOLE_WIDTHand adds a linebreak.static StringbreakString(String theString, int length)Breaks the StringtheStringat positionlengthand adds a linebreak.static StringbreakString(String linePrefix, String theString)Breaks the StringtheStringat positionCONSOLE_WIDTHand adds a linebreak.static StringbreakString(String linePrefix, String theString, int length)Breaks the StringtheStringat positionlengthand adds a linebreak.static StringbreakString2(StringBuilder output, String theString, int length)Returns reststatic CorpusDesc.BuildercreateCorpusDesc()static StringcreateTable(Integer[] length, String[][] map, boolean hasHeader, boolean hasBlanks, boolean drawInnerVerticalLine)Returns a table created from the passed Strings.static StringgetHello()Returns a formatted String, a kind of a welcome screen of Pepper.static StringgetHello(int width, String eMail, String hp)Returns a formatted String, a kind of a welcome screen of Pepper.static FilegetTempFile()Returns a temporary folder, where Pepper and all modules can store temp files.static FilegetTempFile(String segments)Returns a temporary folder, where Pepper and all modules can store temp files.static FilegetTempFile(String segments, String prefix)Returns a temporary folder, where Pepper and all modules can store temp files.static FilegetTempTestFile()Returns a temporary folder, where all tests can store temporary files.static FilegetTempTestFile(String segments)Returns a temporary folder, where all tests can store temporary files.static <T> booleanisNotNullOrEmpty(Collection<T> collection)Checks whether a collection is not null nor emptystatic <T> booleanisNullOrEmpty(Collection<T> collection)Checks whether a collection is null or emptystatic voidreadXMLResource(DefaultHandler2 contentHandler, org.eclipse.emf.common.util.URI documentLocation)Helper method to read an xml file with aDefaultHandler2implementation given as contentHandler.static StringreportConfiguration(PepperConfiguration conf)Returns a report as String containing the configuration for Pepper.static StringreportModuleList(int width, Collection<PepperModuleDesc> moduleDescs)Creates a table containing all passed Pepper modules corresponding to their description and their fingerprintstatic StringreportModuleList(int width, Collection<PepperModuleDesc> moduleDescs, Map<Integer,PepperModuleDesc> number2module)Creates a table containing all passed Pepper modules corresponding to their description and their fingerprint
-
-
-
Field Detail
-
FILE_ENDING_PEPPER
public static final String FILE_ENDING_PEPPER
This is the default ending of a Pepper workflow description file.- See Also:
- Constant Field Values
-
CONSOLE_WIDTH
public static final int CONSOLE_WIDTH
The standard width of the output console of Pepper.- See Also:
- Constant Field Values
-
CONSOLE_WIDTH_120
public static final int CONSOLE_WIDTH_120
The width of the output console of Pepper.- See Also:
- Constant Field Values
-
CONSOLE_WIDTH_80
public static final int CONSOLE_WIDTH_80
The width of the output console of Pepper, when os is windows.- See Also:
- Constant Field Values
-
-
Method Detail
-
getHello
public static String getHello()
Returns a formatted String, a kind of a welcome screen of Pepper.- Returns:
- welcome screen
-
getHello
public static String getHello(int width, String eMail, String hp)
Returns a formatted String, a kind of a welcome screen of Pepper.- Returns:
- welcome screen
-
breakString
public static String breakString(String theString)
Breaks the StringtheStringat positionCONSOLE_WIDTHand adds a linebreak. The manipulated String is returned.- Parameters:
theString- String to be break- Returns:
- the breaked String
-
breakString
public static String breakString(String theString, int length)
Breaks the StringtheStringat positionlengthand adds a linebreak. The manipulated String is returned.- Parameters:
theString- String to be breaklength- position where to break String- Returns:
- the breaked String
-
breakString
public static String breakString(String linePrefix, String theString)
Breaks the StringtheStringat positionCONSOLE_WIDTHand adds a linebreak. The next line than is prefixed bylinePrefix. The manipulated String is returned.- Parameters:
theString- String to be breaklength- position where to break StringlinePrefix- a prefix for all lines- Returns:
- the breaked String
-
breakString
public static String breakString(String linePrefix, String theString, int length)
Breaks the StringtheStringat positionlengthand adds a linebreak. The next line than is prefixed bylinePrefix. The manipulated String is returned.- Parameters:
theString- String to be breaklength- position where to break StringlinePrefix- a prefix for all lines- Returns:
- the breaked String
-
breakString2
public static String breakString2(StringBuilder output, String theString, int length)
Returns rest
-
createTable
public static String createTable(Integer[] length, String[][] map, boolean hasHeader, boolean hasBlanks, boolean drawInnerVerticalLine)
Returns a table created from the passed Strings.- Parameters:
length- an array of lengths for the columnsmap- a map containing the Strings to be printed out sorted as [line, column]hasHeader- determines, if the first line of map contains a header for the tablehasBlanks- determines if vertical lines has to be followed by a blank e.g. with blanks "| cell1 |" or without blanks "|cell1|"drawInnerVerticalLine- determines whether an inner vertical line between two cells has to be drawn e.g. "|cell1 | cell2|" or "|cell1 cell2|"- Returns:
-
getTempTestFile
public static File getTempTestFile(String segments)
Returns a temporary folder, where all tests can store temporary files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.- Parameters:
segments- segments or subfolders to be attached to the created temp folder, subfolders are separated by '/'- Returns:
- path, where to store temporary files
-
getTempTestFile
public static File getTempTestFile()
Returns a temporary folder, where all tests can store temporary files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.- Returns:
- path, where to store temporary files
-
getTempFile
public static File getTempFile()
Returns a temporary folder, where Pepper and all modules can store temp files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper' and the users name or a randomized unique sequence of characters, if the user name is not available.- Returns:
- path, where to store temporary files
-
getTempFile
public static File getTempFile(String segments)
Returns a temporary folder, where Pepper and all modules can store temp files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.- Parameters:
segments- segments or subfolders to be attached to the created temp folder, subfolders are separated by '/'- Returns:
- path, where to store temporary files
-
getTempFile
public static File getTempFile(String segments, String prefix)
Returns a temporary folder, where Pepper and all modules can store temp files. The returned temporary folder is a combination of the systems standard temp folder, the prefix 'pepper', and the users name or a randomized unique sequence of characters, if the user name is not available and suffixed by the passed segments.- Parameters:
segments- segments or subfolders to be attached to the created temp folder, subfolders are separated by '/'prefix- the prefix to be used like 'pepper' or pepper-test etc.- Returns:
- path, where to store temporary files
-
reportConfiguration
public static String reportConfiguration(PepperConfiguration conf)
Returns a report as String containing the configuration for Pepper.- Returns:
-
reportModuleList
public static String reportModuleList(int width, Collection<PepperModuleDesc> moduleDescs, Map<Integer,PepperModuleDesc> number2module)
Creates a table containing all passed Pepper modules corresponding to their description and their fingerprint- Parameters:
maximal- width of the returned stringmoduleDescs- all modules to be listednumber2module- a map containing a module description and a corresponding number for identification- Returns:
- a table displaying all passed modules and a corresponding description
-
reportModuleList
public static String reportModuleList(int width, Collection<PepperModuleDesc> moduleDescs)
Creates a table containing all passed Pepper modules corresponding to their description and their fingerprint- Parameters:
maximal- width of the returned stringmoduleDescs- all modules to be listednumber2module- a map containing a module description and a corresponding number for identification- Returns:
- a table displaying all passed modules and a corresponding description
-
readXMLResource
public static void readXMLResource(DefaultHandler2 contentHandler, org.eclipse.emf.common.util.URI documentLocation)
Helper method to read an xml file with aDefaultHandler2implementation given as contentHandler. It is assumed, that the file encoding is set to UTF-8.- Parameters:
contentHandler-DefaultHandler2implementationdocumentLocation- location of the xml-file
-
createCorpusDesc
public static CorpusDesc.Builder createCorpusDesc()
-
isNullOrEmpty
public static <T> boolean isNullOrEmpty(Collection<T> collection)
Checks whether a collection is null or empty- Parameters:
list-- Returns:
-
isNotNullOrEmpty
public static <T> boolean isNotNullOrEmpty(Collection<T> collection)
Checks whether a collection is not null nor empty- Parameters:
list-- Returns:
-
-