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

annis.service.objects.RawTextWrapper Maven / Gradle / Ivy

There is a newer version: 4.0.0-beta.4
Show newest version
/*
 * Copyright 2013 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.service.objects;

import java.io.Serializable;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Wrapper for the rest api call for extracting the raw text.
 *
 * @author Benjamin Weißenfels {@literal }
 */
@XmlRootElement
public class RawTextWrapper implements Serializable
{

  // holds the texts of a document.
  List texts;

  /**
   * Sets the texts of a document.
   * @param texts Can be null or empty.
   */
  public void setTexts(List texts){
    this.texts = texts;
  }

  /**
   * Returns a list of all texts.
   *
   * @return If the document only uses segmentations and has only an artificial
   * token layer this list of strings is null
   */
  public List getTexts()
  {
    return texts;
  }

  /**
   * Checks, whether at least one text exists
   * @return True if there is at least one text.
   */
  public boolean hasTexts()
  {
    return texts != null && !texts.isEmpty();
  }

  /**
   * Checks, if multiple texts are stored for one document.
   *
   * @return true if there are more than 1 text.
   */
  public boolean hasMultipleTexts()
  {
    return texts != null && texts.size() > 1;
  }

  /**
   * Extracts first text or an empty string, when texts are empty.
   *
   * @return A string, which represents the first text of a document.
   */
  public String getFirstText()
  {
    return texts != null && !texts.isEmpty() ? texts.get(0) : "";
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy