Commit d4a447aa authored by Custom2043's avatar Custom2043
Browse files

Add getStartEndIgnored

parent 1ea3048b
No preview for this file type
......@@ -93,6 +93,38 @@ public abstract class Token
{
return this.ignored;
}
public Result getLastIgnoredResult()
{
return this.ignored[this.ignored.length - 1];
}
public String getStartIgnored()
{
StringBuilder builder = new StringBuilder();
this.getStartIgnored(builder);
return builder.toString();
}
public String getEndIgnored()
{
StringBuilder builder = new StringBuilder();
this.getEndIgnored(builder);
return builder.toString();
}
private void getStartIgnored(StringBuilder builder)
{
if (this.ignored.length > 0)
builder.append(this.ignored[0].getTotal());
if (this.totalTokens.length > 0)
this.totalTokens[0].getStartIgnored(builder);
}
private void getEndIgnored(StringBuilder builder)
{
if (this.ignored.length > 0)
builder.append(this.ignored[this.ignored.length - 1].getTotal());
if (this.totalTokens.length > 0)
this.totalTokens[this.totalTokens.length - 1].getEndIgnored(builder);
}
@Override
public String toString()
......
......@@ -157,47 +157,6 @@ public class TokenBuilder extends Builder
ignoredResults.toArray(new Result[ignoredResults.size()])};
}
public Result[] getResultWithoutIgnores(Result[] results)
{
return this.getResultWithoutIgnores(results, this.searchesWithIgnore);
}
private Result[] getResultWithoutIgnores(Result[] results, Search[] searchesWithIgnore)
{
if (this.getIgnore() == null || results == null)
return results;
List<Result> resultWithoutIgnore = new LinkedList<>();
int position = 0;
for (Search s : searchesWithIgnore)
{
if (s != this.ignore.getRealSearch())
if (s instanceof ArraySearch)
{
Result[] array = results[position].getArray();
Search[] toSearchIn;
List<Result> r = new LinkedList<>();
for (int i=0;i<array.length;i++)
{
toSearchIn = ((BracketSearch)array[i].getSearch()).getSearches();
r.add(new Result(new BracketSearch(toSearchIn), this.getResultWithoutIgnores(array[i].getArray(), toSearchIn)));
}
resultWithoutIgnore.add(new Result(s, r.toArray(new Result[r.size()])));
}
else if (s instanceof OrSearch || s instanceof TokenSearch)
resultWithoutIgnore.add(results[position]);
else if (s instanceof MultipleSearch)
resultWithoutIgnore.add(new Result(results[position].getSearch(), this.getResultWithoutIgnores(results[position].getArray(), ((MultipleSearch) s).getSearches())));
position ++;
}
return resultWithoutIgnore.toArray(new Result[resultWithoutIgnore.size()]);
}
@Override
public boolean isTokenCorrect(Token current)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment