All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.unlaxer.jaddress.parser.picker.SequenceReverseScanner Maven / Gradle / Ivy

package org.unlaxer.jaddress.parser.picker;

//import java.util.ListIterator;
//import java.util.Optional;
//import java.util.function.Predicate;
//
//import org.unlaxer.jaddress.parser.CharacterKind;
//import org.unlaxer.jaddress.parser.MatchedString;
//import org.unlaxer.jaddress.parser.StringAndCharacterKind;
//import org.unlaxer.jaddress.parser.StringAndCharacterKinds;

public abstract class SequenceReverseScanner{
		
//	static final Predicate skips = CharacterKind::isDelimitorSpace;
//
//	public Optional scan(StringAndCharacterKinds stringAndCharacterKinds){
//		
//		ListIterator iterator = stringAndCharacterKinds.listIteratorFromLast();
//		
//		Predicate targetKindPredicate = targetKindPredicate();
//		
//		boolean skipSpace = skipSpace(iterator);
//		
//		int toIndexExclusive = iterator.previousIndex()+ 1;//(skipSpace ? 0 : 1);
//		int fromIndex = iterator.previousIndex();
//		
//		boolean match = false;
//		while(iterator.hasPrevious()) {
//			
//			StringAndCharacterKind previous = iterator.previous();
//			if(targetKindPredicate.test(previous.characterKind())) {
//				fromIndex = iterator.previousIndex();
//				match = true;
//			}else {
//				break;
//			}
//		}
//		return match ?
//				Optional.of(
//					stringAndCharacterKinds.createTriplet(fromIndex+1, toIndexExclusive)
//				):
//				Optional.empty();
//	}
//	
//	boolean skipSpace(ListIterator iterator) {
//		
//		if(iterator.hasPrevious()) {
//			StringAndCharacterKind previous = iterator.previous();
//			CharacterKind characterKind = previous.characterKind();
//			if(skipKindPredicate().test(characterKind)) {
//				return true;
//			}else {
//				iterator.next();
//			}
//		}
//		return false;
//	}
//	
//	public static boolean skip(
//			ListIterator iterator , 
//			Predicate predicate) {
//		
//		boolean skipped = false;
//		
//		while(iterator.hasPrevious()) {
//			
//			StringAndCharacterKind previous = iterator.previous();
//			CharacterKind characterKind = previous.characterKind();
//			
//			if(predicate.test(characterKind)) {
//				skipped = true;
//			}else {
//				iterator.next();
//			}
//		}
//		return skipped;
//	}
//	
//	public abstract Predicate targetKindPredicate();
//	
//	public Predicate skipKindPredicate(){
//		return skips;
//	}
//	
//	public interface BiDirectionalParser{
//		
//	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy