Package org.silverpeas.core.util
Class StringDataExtractor
- java.lang.Object
-
- org.silverpeas.core.util.StringDataExtractor
-
public class StringDataExtractor extends Object
- Author:
- Yohann Chastagnier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StringDataExtractor.ExtractorDirective
This interface permits to implement several way to extract data from a string.static class
StringDataExtractor.RegexpPatternDirective
Class that permits to specify the directives in order to extract data.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
extract()
Extracts data from a strict by applying the specified extract pattern directives.String
extractUnique()
Calls firstextract()
and then return the only contained value from the result, null if no value extracted.static StringDataExtractor
from(String source)
Gets an instance ofStringDataExtractor
StringDataExtractor
withDirective(StringDataExtractor.ExtractorDirective directive)
Indicates a directive of data extraction.StringDataExtractor
withDirectives(List<? extends StringDataExtractor.ExtractorDirective> directives)
Indicates a directive of data extraction.
-
-
-
Method Detail
-
from
public static StringDataExtractor from(String source)
Gets an instance ofStringDataExtractor
- Parameters:
source
- the string from which data must be extracted.- Returns:
- an instance of
StringDataExtractor
-
withDirective
public StringDataExtractor withDirective(StringDataExtractor.ExtractorDirective directive)
Indicates a directive of data extraction.- Parameters:
directive
- the directive that will handle the data extraction.- Returns:
- the current instance of
StringDataExtractor
.
-
withDirectives
public StringDataExtractor withDirectives(List<? extends StringDataExtractor.ExtractorDirective> directives)
Indicates a directive of data extraction.- Parameters:
directives
- the directives that will handle the data extraction.- Returns:
- the current instance of
StringDataExtractor
.
-
extract
public List<String> extract()
Extracts data from a strict by applying the specified extract pattern directives.- Returns:
- the list of data.
-
extractUnique
public String extractUnique() throws IllegalStateException
Calls firstextract()
and then return the only contained value from the result, null if no value extracted.- Returns:
- the unique value aimed by the extraction.
- Throws:
IllegalStateException
- if it exists several values behind the extraction directive.
-
-