TexaiSamplePhrase.java from Texai at Krugle
Show TexaiSamplePhrase.java syntax highlighted
/*
* TexaiSamplePhrase.java
*
* Created on February 28, 2007, 8:43 PM
*
* Description: Provides domain entities that contain sample phrases.
*
* Copyright (C) 2007 Stephen L. Reed.
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.texai.lexicon.domainEntity;
import javax.persistence.Id;
import org.texai.kb.Constants;
import org.texai.kb.persistence.DomainEntity;
import org.texai.kb.persistence.DomainProperty;
/**
*
* @author reed
*/
@DomainEntity(typeOf="LinguisticObjectType", subClassOf="AbstractInformationStructure")
public class TexaiSamplePhrase {
/** the term id inserted by the container */
@Id
private Long termId; // NOPMD
/** the sample phrase */
@DomainProperty(name="texaiSamplePhraseText", range="CharacterString", functional=true)
private String samplePhrase; // NOPMD
/** the word sense for which this is a sample phrase */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_WORD_SENSE_SAMPLE_PHRASE, inverse=true)
private TexaiEnglishWordSense texaiEnglishWordSense;
/** Creates a new instance of TexaiSamplePhrase. */
public TexaiSamplePhrase() {
super();
}
/** Creates a new instance of TexaiSamplePhrase.
*
* @param samplePhrase the sample phrase
* @param texaiEnglishWordSense the word sense for which this is a sample phrase
*/
public TexaiSamplePhrase(final String samplePhrase, final TexaiEnglishWordSense texaiEnglishWordSense) {
super();
//Preconditions
assert samplePhrase != null : "samplePhrase must not be null";
assert !samplePhrase.isEmpty() : "samplePhrase must not be an empty string";
assert texaiEnglishWordSense != null : "texaiEnglishWordSense must not be null";
this.samplePhrase = samplePhrase;
this.texaiEnglishWordSense = texaiEnglishWordSense;
}
/** Gets the term id inserted by the container.
*
* @return the term id inserted by the container
*/
public Long getTermId() {
return termId;
}
/** Gets the sample phrase.
*
* @return the sample phrase
*/
public String getSamplePhrase() {
return samplePhrase;
}
/** Sets the sample phrase.
*
* @param samplePhrase the sample phrase
*/
public void setSamplePhrase(String samplePhrase) {
//Preconditions
assert samplePhrase != null : "samplePhrase must not be null";
assert !samplePhrase.isEmpty() : "samplePhrase must not be an empty string";
this.samplePhrase = samplePhrase;
}
/** Gets the word sense for which this is a sample phrase.
*
* @return the word sense for which this is a sample phrase
*/
public TexaiEnglishWordSense getTexaiEnglishWordSense() {
return texaiEnglishWordSense;
}
/** Sets the word sense for which this is a sample phrase.
*
* @param texaiEnglishWordSense the word sense for which this is a sample phrase
*/
public void setTexaiEnglishWordSense(TexaiEnglishWordSense texaiEnglishWordSense) {
//Preconditions
assert texaiEnglishWordSense != null : "texaiEnglishWordSense must not be null";
this.texaiEnglishWordSense = texaiEnglishWordSense;
}
/** Returns whether the given object is equal to this object.
*
* @param obj the given object
* @return whether the given object is equal to this object
*/
@Override
public boolean equals(final Object obj) {
if (obj instanceof TexaiSamplePhrase) {
final TexaiSamplePhrase that = (TexaiSamplePhrase) obj;
return this.getTermId().equals(that.getTermId());
} else {
return false;
}
}
/** Returns a hash code for this object.
*
* @return a hash code for this object
*/
@Override
public int hashCode() {
if (getTermId() == null) {
return super.hashCode();
} else {
return getTermId().hashCode();
}
}
/** Returns a string representation of this object.
*
* @return a string representation of this object
*/
@Override
public String toString() {
final StringBuilder stringBuilder = new StringBuilder(Constants.STRING_BUILDER_SIZE);
stringBuilder.append("[SAMPLE PHRASE \"");
stringBuilder.append(samplePhrase);
stringBuilder.append("\"]");
return stringBuilder.toString();
}
}
See more files for this project here