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

com.altova.text.flex.SplitAtDelimiterLineStartsWith Maven / Gradle / Ivy

////////////////////////////////////////////////////////////////////////
//
// SplitAtDelimiterLineStartsWith.java
//
// This file was generated by MapForce 2017sp2.
//
// YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
// OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
//
// Refer to the MapForce Documentation for further details.
// http://www.altova.com/mapforce
//
////////////////////////////////////////////////////////////////////////

package com.altova.text.flex;

public class SplitAtDelimiterLineStartsWith extends SplitAtDelimiter {
	protected boolean consumeFirstLine;

	public SplitAtDelimiterLineStartsWith(String delimiter) {
		super(delimiter, false);
		consumeFirstLine = false;
	}
	
	public SplitAtDelimiterLineStartsWith(String delimiter, boolean reverse) {
		super(delimiter, reverse);
		consumeFirstLine = false;
	}
	
	public Range split(Range range) {
		if (!reverse)
		{
			Range result = new Range(range);

			if ( delimiter == "" )
			{
				range.start = range.end;
				return result;
			}

			SplitLines splitAtFirstLine = new SplitLines(1);
			boolean firstLine = consumeFirstLine;
			while (true)
			{
				Range line = splitAtFirstLine.split(range);
				if (!line.isValid())
				{
					result.end = line.start;
					break;
				}
				if (line.toString().indexOf(delimiter) == 0)
				{
					if (!firstLine)
					{
						result.end = line.start;
						break;
					}
				}
				firstLine = false;
			}
			range.start = result.end;
			return result;
		}
		else
		{
			Range result = new Range(range);

			if ( delimiter == "" )
			{
				result.end = result.start;
				return result;
			}

			SplitLines splitAtLastLine = new SplitLines(-1);
			Range pre = new Range(range);
			while (true)
			{
				Range line = splitAtLastLine.split(pre);
				if (!line.isValid())
				{
					result.end = line.start;
					break;
				}
				if (pre.toString().indexOf(delimiter) == 0)
				{
					result.end = pre.start;
					break;
				}
				pre = line;
			}
			range.start = result.end;
			return result;
		}
	}
	
	public void appendDelimiter(Appender output) {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy