completed some javadoc on compile and constructor methods

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2018-03-07 22:10:35 +11:00
parent 809aee129e
commit bfbe52754b
2 changed files with 17 additions and 4 deletions

View File

@ -41,19 +41,31 @@ public class SearchPattern
private int[] table;
private byte[] pattern;
/**
* Produces a SearchPattern instance which can be used
* to find matches of the pattern in data
* @param pattern byte array containing the pattern
* @return a new SearchPattern instance using the given pattern
*/
public static SearchPattern compile(byte[] pattern)
{
return new SearchPattern(Arrays.copyOf(pattern, pattern.length));
}
/**
* Produces a SearchPattern instance which can be used
* to find matches of the pattern in data
* @param pattern string containing the pattern
* @return a new SearchPattern instance using the given pattern
*/
public static SearchPattern compile(String pattern)
{
return new SearchPattern(pattern.getBytes(StandardCharsets.UTF_8));
}
/**
* @param pattern byte array containing the pattern used for matching
*/
private SearchPattern(byte[] pattern)
{
this.pattern = pattern;

View File

@ -25,7 +25,8 @@ import java.nio.charset.StandardCharsets;
import org.junit.Assert;
import org.junit.Test;
public class SearchPatternTest
public class
{