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

org.etlunit.util.regexp.InfaDeleteConnectionDoesNotExistExpression Maven / Gradle / Ivy

There is a newer version: 1.6.9
Show newest version
package org.etlunit.util.regexp;

/*

		Regular expression class compiled by the Regular Expression Compiler 1.5.0-SNAPSHOT

*/

import java.util.Map;
import java.util.HashMap;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public final class InfaDeleteConnectionDoesNotExistExpression
{
	public static final String PATTERN_RAW_TEXT = "Connection name \\[(?{connectionName})\\] of type \\[relational\\] does not exist in the repository";
	private final String parameter_connectionName;
	public final String pattern_text;
	public final Pattern pattern;
	private final Map groupOffsets = new HashMap();

	private final Matcher matcher;
	private final CharSequence matchText;

	public static interface RegExpIterator
	{
		String replaceMatch(InfaDeleteConnectionDoesNotExistExpression e);
	}


	public InfaDeleteConnectionDoesNotExistExpression(CharSequence ch, String connectionName)
	{
		String s_pattern_text = PATTERN_RAW_TEXT.replaceAll("\\(\\?'[^']+'", "(");

		//connectionName >> (?{connectionName});
		parameter_connectionName = connectionName;

		s_pattern_text = s_pattern_text.replace("(?{connectionName})", parameter_connectionName);

		pattern_text = s_pattern_text;

		Pattern cpattern = Pattern.compile("(\\\\)?\\((\\?'([^']+)')?");

		Matcher m = cpattern.matcher(PATTERN_RAW_TEXT);

		int groupCount = 1;

		while (m.find())
		{
			if (m.group(1) != null)
			{
				continue;
			}

			String groupName = m.group(3);

			if (groupName != null)
			{
				groupOffsets.put(groupName, new Integer(groupCount));
			}

			groupCount++;
		}

		pattern = Pattern.compile(pattern_text, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);

		matchText = ch;
		matcher = pattern.matcher(matchText);
	}

	public static InfaDeleteConnectionDoesNotExistExpression match(CharSequence pText, String connectionName)
	{
		return new InfaDeleteConnectionDoesNotExistExpression(pText, connectionName);
	}

	public int end()
	{
		return matcher.end();
	}

	public int end(int group)
	{
		return matcher.end(group);
	}

	public int start()
	{
		return matcher.start();
	}

	public int start(int group)
	{
		return matcher.start(group);
	}

	public String replaceAll(String replacement)
	{
		return matcher.replaceAll(replacement);
	}

	public String replaceAll(RegExpIterator it)
	{
		String match = matchText.toString();
		String str = "";
		int end = -1;

		while (hasNext())
		{
			str += match.substring(end == -1 ? 0 : end, start());
			str += it.replaceMatch(this);
			end = end();
		}

		str += match.substring(end == -1 ? 0 : end, match.length());
		return str;
	}

	public boolean matches()
	{
		return matcher.matches();
	}

	public boolean hasNext()
	{
		return matcher.find();
	}

	public int groupCount()
	{
		return matcher.groupCount();
	}

	public String group()
	{
		return matcher.group();
	}

	public String group(int i)
	{
		return matcher.group(i);
	}

	public InfaDeleteConnectionDoesNotExistExpression resetMatch(CharSequence seq, String connectionName)
	{
		return match(seq, connectionName);
	}

	public String group(String name)
	{
		return matcher.group(groupOffsets.get(name).intValue());
	}

	private static String scope(String text, String name)
	{
		return text.replaceAll("(\\(\\?')(\\w+')", "$1" + name + ".$2");
	}

	public final String getconnectionNameParameter()
	{
		return parameter_connectionName;
	}



	public String toString()
	{
		return "{InfaDeleteConnectionDoesNotExistExpression, matchText='" + matchText + "'}[" + "]";
	}

	public static void main(String [] argv)
	{
		System.out.println(PATTERN_RAW_TEXT);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy