/*
 * Copyright 2009-2011 Collaborative Research Centre SFB 632 
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package annis.model;

import annis.model.QueryNode.TextMatching;
import java.io.Serializable;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

public class QueryAnnotation implements Comparable<QueryAnnotation>, Serializable
{

	// this class is sent to the front end
	

	private String namespace;
	private String name;
	private String value;
	private String type;
	private String corpusName;
	private TextMatching textMatching;

  public QueryAnnotation()
  {
    this("", "");
  }
  
	public QueryAnnotation(String namespace, String name)
	{
		this(namespace, name, null, null);
	}

	public QueryAnnotation(String namespace, String name, String value)
	{
		this(namespace, name, value, TextMatching.EXACT_EQUAL);
	}

	public QueryAnnotation(String namespace, String name, String value,
			TextMatching textMatching)
	{
		this.namespace = namespace;
		this.name = name;
		this.value = value;
		this.textMatching = textMatching;
	}

	public QueryAnnotation(String namespace, String name, String value, String type,
			String corpusName)
	{
		this(namespace, name, value);
		this.type = type;
		this.corpusName = corpusName;
	}

	@Override
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		sb.append(QueryNode.qName(namespace, name));
		if (value != null)
		{
			sb.append(" ");
			sb.append(textMatching);
			sb.append(" ");
			sb.append(value);
		}
		return sb.toString();
	}

	public int compareTo(QueryAnnotation o)
	{
		String name1 = getQualifiedName();
		String name2 = o.getQualifiedName();
		return name1.compareTo(name2);
	}

	@Override
	public boolean equals(Object obj)
	{
		if (obj == null || !(obj instanceof QueryAnnotation))
			return false;

		QueryAnnotation other = (QueryAnnotation) obj;

		return new EqualsBuilder().append(this.namespace, other.namespace)
				.append(this.name, other.name).append(this.value, other.value)
				.append(this.textMatching, other.textMatching).isEquals();
	}

	@Override
	public int hashCode()
	{
		return new HashCodeBuilder().append(namespace).append(name)
				.append(value).append(textMatching).toHashCode();
	}

	// /// Getter / Setter

	public String getValue()
	{
		return value;
	}

	public void setValue(String value)
	{
		this.value = value;
	}

	public TextMatching getTextMatching()
	{
		return textMatching;
	}

	public void setTextMatching(TextMatching textMatching)
	{
		this.textMatching = textMatching;
	}

	public String getNamespace()
	{
		return namespace;
	}

	public void setNamespace(String namespace)
	{
		this.namespace = namespace;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getQualifiedName()
	{
		return QueryNode.qName(namespace, name);
	}

	public String getType()
	{
		return type;
	}

	public String getCorpusName()
	{
		return corpusName;
	}
}
@@ -915,51 +915,8 @@
 %0A%7B%0A%0A
-%09// this class is sent to the front end%0A%09%0A%0A
 %09pri
@@ -1009,36 +1009,8 @@
 pe;%0A
-%09private String corpusName;%0A
 %09pri
@@ -1183,14 +1183,8 @@
 ame,
- null,
  nul
@@ -1623,30 +1623,8 @@
 type
-,%0A%09%09%09String corpusName
 )%0A%09%7B
@@ -1680,40 +1680,8 @@
 pe;%0A
-%09%09this.corpusName = corpusName;%0A
 %09%7D%0A%0A
@@ -3329,63 +3329,5 @@
 %09%7D%0A%0A
-%09public String getCorpusName()%0A%09%7B%0A%09%09return corpusName;%0A%09%7D%0A
 %7D

remove corpus name from queryannotation