package com.exedio.cope;

import com.exedio.cope.function.LengthView;
import com.exedio.cope.function.UppercaseView;

public class JoinedStringFunction extends JoinedFunction<String> implements StringFunction
{

	final StringFunction stringFunction;
	
	/**
	 * Instead of using this constructor directly,
	 * you may want to use the convenience methods.
	 * @see IntegerFunction#bindInt(Join)
	 */
	public JoinedStringFunction(final StringFunction function, final Join join)
	{
		super(function, join);
		this.stringFunction = function;
	}
	
	/**
	 * Return this.
	 * It makes no sense wrapping a JoinedFunction into another JoinedFunction,
	 * because the inner JoinedFunction &quot;wins&quot;.
	 * @see JoinedFunction#bind(Join)
	 * @see JoinedIntegerFunction#bindInt(Join)
	 * @see JoinedItemFunction#bindItem(Join)
	 */
	public JoinedStringFunction bindString(final Join join)
	{
		return new JoinedStringFunction(stringFunction, join); // using "integerFunction" instead of "this" is a small short-cut
	}
	
	public final LikeCondition like(final String value)
	{
		return new LikeCondition(this, value);
	}
	
	public final LikeCondition startsWith(final String value)
	{
		return LikeCondition.startsWith(this, value);
	}
	
	public final LikeCondition endsWith(final String value)
	{
		return LikeCondition.endsWith(this, value);
	}
	
	public final LikeCondition contains(final String value)
	{
		return LikeCondition.contains(this, value);
	}
	
	public final LengthView length()
	{
		return new LengthView(this);
	}
	
	public final UppercaseView toUpperCase()
	{
		return new UppercaseView(this);
	}
	
	public final EqualCondition equalIgnoreCase(final String value)
	{
		return toUpperCase().equal(value.toUpperCase());
	}
	
	public final LikeCondition likeIgnoreCase(final String value)
	{
		return toUpperCase().like(value.toUpperCase());
	}
	
	public final LikeCondition startsWithIgnoreCase(final String value)
	{
		return LikeCondition.startsWith(toUpperCase(), value.toUpperCase());
	}
	
	public final LikeCondition endsWithIgnoreCase(final String value)
	{
		return LikeCondition.endsWith(toUpperCase(), value.toUpperCase());
	}
	
	public final LikeCondition containsIgnoreCase(final String value)
	{
		return LikeCondition.contains(toUpperCase(), value.toUpperCase());
	}
}

@@ -1,8 +1,812 @@
+/*%0A * Copyright (C) 2004-2006  exedio GmbH (www.exedio.com)%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA%0A */%0A%0A
 package 
@@ -1694,121 +1694,13 @@
 urn 
-new JoinedStringFunction(stringFunction, join); // using %22integerFunction%22 instead of %22this%22 is a small short-cut
+this;
 %0A%09%7D%0A

fix bindString from r5927, add LGPL header