org.appng.search.indexer

## Class SimpleDocument

- java.lang.Object
- - org.appng.search.indexer.SimpleDocument

- All Implemented Interfaces:
    Comparable<Document>, Observable<Document>, Document

      public class SimpleDocument
      extends Object
      implements Document

  A basic `Document`-implementation, suitable for most cases. Uses an `ObservableDelegate` to manage its `Observer`s.
  Author:
    Matthias Müller

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.appng.api.observe.Observable

      `Observable.Event`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static org.apache.commons.lang3.time.FastDateFormat` | `DATEFORMAT`

    - ### Fields inherited from interface org.appng.api.search.Document

      `CREATE, DELETE, FIELD_CONTENT, FIELD_DATE, FIELD_ID, FIELD_IMAGE, FIELD_LANGUAGE, FIELD_PATH, FIELD_TEASER, FIELD_TITLE, FIELD_TYPE, UPDATE, YYYY_MM_DD_HH_MM_SS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleDocument()`
    `SimpleDocument(float score)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addField(org.apache.lucene.index.IndexableField field)`
    `boolean` | `addObserver(Observer<? super Document> observer)` Adds an `Observer`.
    `int` | `compareTo(Document other)`
    `static SimpleDocument` | `extract(org.apache.lucene.document.Document doc, int docId, float score)`
    `Iterable<org.apache.lucene.index.IndexableField>` | `getAdditionalFields()` Returns some additionally `IndexableField`s (if any) to be added to the `Document` which is being created from this `Document`.
    `String` | `getContent()` Returns the content to be indexed.
    `Date` | `getDate()` Returns the `Date` of the last modification of this `Document`.
    `String` | `getDescription()` Returns the description of this `Document`.
    `int` | `getDocId()`
    `org.apache.lucene.index.IndexableField` | `getField(String name)`
    `String` | `getFragment()`
    `String` | `getId()` Returns the ID of this `Document`. Has to be globally unique, speaking in the scope of a `Site`, since each site has it's own searchindex.
    `String` | `getImage()`
    `String` | `getLanguage()` Returns the language of this `Document`.
    `String` | `getName()` Returns the name of this `Document`.
    `protected static Number` | `getNumberFromField(org.apache.lucene.document.Document doc, String name, List<org.apache.lucene.index.IndexableField> fieldsList)`
    `Observable<Document>` | `getObservable()`
    `String` | `getPath()` Returns the path of this `Document`, relative to the `Site`s domain.
    `float` | `getScore()`
    `String` | `getType()` Returns the type of this `Document`, to be used when searching `Document`s of a certain type.
    `void` | `notifyObservers(Observable.Event event)` Notifies the `Observer`s.
    `boolean` | `removeObserver(Observer<? super Document> observer)` Removes an `Observer`.
    `void` | `setContent(String content)`
    `void` | `setDate(Date date)`
    `void` | `setDescription(String description)`
    `void` | `setDocId(int docId)`
    `static void` | `setFragment(SimpleDocument doc, String field, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.Query query, String highlightWith)`
    `void` | `setFragment(String fragment)`
    `void` | `setFragment(String field, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.search.Query query, String highlightWith)`
    `void` | `setId(String id)`
    `void` | `setImage(String image)`
    `void` | `setLanguage(String language)`
    `void` | `setName(String name)`
    `void` | `setObservable(Observable<Document> observable)`
    `void` | `setPath(String path)`
    `void` | `setScore(float score)`
    `void` | `setType(String type)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DATEFORMAT

          public static final org.apache.commons.lang3.time.FastDateFormat DATEFORMAT

  - ### Constructor Detail

    - #### SimpleDocument

          public SimpleDocument()

    - #### SimpleDocument

          public SimpleDocument(float score)

  - ### Method Detail

    - #### addObserver

          public boolean addObserver(Observer<? super Document> observer)

      Description copied from interface: `Observable`
      Adds an `Observer`.
      Specified by:
        `addObserver` in interface `Observable<Document>`
      Parameters:
        `observer` - the `Observer` to be added
      Returns:
        `true` if adding the `Observer` was successful, `false` otherwise

    - #### removeObserver

          public boolean removeObserver(Observer<? super Document> observer)

      Description copied from interface: `Observable`
      Removes an `Observer`.
      Specified by:
        `removeObserver` in interface `Observable<Document>`
      Parameters:
        `observer` - the `Observer` to be removed
      Returns:
        `true` if removing the `Observer` was successful, `false` otherwise

    - #### notifyObservers

          public void notifyObservers(Observable.Event event)

      Description copied from interface: `Observable`
      Notifies the `Observer`s.
      Specified by:
        `notifyObservers` in interface `Observable<Document>`
      Parameters:
        `event` - an `Observable.Event`

    - #### getAdditionalFields

          public Iterable<org.apache.lucene.index.IndexableField> getAdditionalFields()

      Description copied from interface: `Document`
      Returns some additionally `IndexableField`s (if any) to be added to the `Document` which is being created from this `Document`.
      Specified by:
        `getAdditionalFields` in interface `Document`
      Returns:
        some `IndexableField`s

    - #### addField

          public void addField(org.apache.lucene.index.IndexableField field)

    - #### getField

          public org.apache.lucene.index.IndexableField getField(String name)

      Specified by:
        `getField` in interface `Document`

    - #### getObservable

          public Observable<Document> getObservable()

    - #### setObservable

          public void setObservable(Observable<Document> observable)

    - #### getLanguage

          public String getLanguage()

      Description copied from interface: `Document`
      Returns the language of this `Document`.
      Specified by:
        `getLanguage` in interface `Document`
      Returns:
        the language

    - #### setLanguage

          public void setLanguage(String language)

    - #### getType

          public String getType()

      Description copied from interface: `Document`
      Returns the type of this `Document`, to be used when searching `Document`s of a certain type.
      Specified by:
        `getType` in interface `Document`
      Returns:
        the type

    - #### setType

          public void setType(String type)

    - #### getContent

          public String getContent()

      Description copied from interface: `Document`
      Returns the content to be indexed.
      Specified by:
        `getContent` in interface `Document`
      Returns:
        the content to be indexed

    - #### setContent

          public void setContent(String content)

    - #### getPath

          public String getPath()

      Description copied from interface: `Document`
      Returns the path of this `Document`, relative to the `Site`s domain.
      Specified by:
        `getPath` in interface `Document`
      Returns:
        the path of this `Document`, relative to the `Site`s domain

    - #### setPath

          public void setPath(String path)

    - #### getImage

          public String getImage()

      Specified by:
        `getImage` in interface `Document`

    - #### setImage

          public void setImage(String image)

    - #### getDescription

          public String getDescription()

      Description copied from interface: `Document`
      Returns the description of this `Document`.
      Specified by:
        `getDescription` in interface `Document`
      Returns:
        the description of this `Document`

    - #### setDescription

          public void setDescription(String description)

    - #### getDate

          public Date getDate()

      Description copied from interface: `Document`
      Returns the `Date` of the last modification of this `Document`.
      Specified by:
        `getDate` in interface `Document`
      Returns:
        the `Date` of the last modification of this `Document`

    - #### setDate

          public void setDate(Date date)

    - #### getName

          public String getName()

      Description copied from interface: `Document`
      Returns the name of this `Document`.
      Specified by:
        `getName` in interface `Document`
      Returns:
        the name

    - #### setName

          public void setName(String name)

    - #### getId

          public String getId()

      Description copied from interface: `Document`
      Returns the ID of this `Document`.
      Has to be globally unique, speaking in the scope of a `Site`, since each site has it's own searchindex.
      Specified by:
        `getId` in interface `Document`
      Returns:
        the ID

    - #### setId

          public void setId(String id)

    - #### getDocId

          public int getDocId()

      Specified by:
        `getDocId` in interface `Document`

    - #### setDocId

          public void setDocId(int docId)

    - #### getScore

          public float getScore()

      Specified by:
        `getScore` in interface `Document`

    - #### setScore

          public void setScore(float score)

    - #### getFragment

          public String getFragment()

      Specified by:
        `getFragment` in interface `Document`

    - #### setFragment

          public void setFragment(String fragment)

      Specified by:
        `setFragment` in interface `Document`

    - #### compareTo

          public int compareTo(Document other)

      Specified by:
        `compareTo` in interface `Comparable<Document>`

    - #### extract

          public static SimpleDocument extract(org.apache.lucene.document.Document doc,
                                               int docId,
                                               float score)

    - #### getNumberFromField

          protected static Number getNumberFromField(org.apache.lucene.document.Document doc,
                                                     String name,
                                                     List<org.apache.lucene.index.IndexableField> fieldsList)

    - #### setFragment

          public void setFragment(String field,
                                  org.apache.lucene.analysis.Analyzer analyzer,
                                  org.apache.lucene.search.Query query,
                                  String highlightWith)

    - #### setFragment

          public static void setFragment(SimpleDocument doc,
                                         String field,
                                         org.apache.lucene.analysis.Analyzer analyzer,
                                         org.apache.lucene.search.Query query,
                                         String highlightWith)

Copyright © 2011–2023 aiticon GmbH. All rights reserved.