Package morfologik.stemming
Class WordData
- java.lang.Object
-
- morfologik.stemming.WordData
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class WordData extends java.lang.Object implements java.lang.CloneableStem and tag data associated with a given word. Instances of this class are reused and mutable (values returned fromgetStem(),getWord()and other related methods change on subsequent calls toDictionaryLookupclass that returned a given instance ofWordData. If you need a copy of the stem or tag data for a given word, you have to create a custom buffer yourself and copy the associated data, performclone()or create strings (they are immutable) usinggetStem()and thenCharSequence.toString(). For reasons above it makes no sense to use instances of this class in associative containers or lists. In fact, bothequals(Object)andhashCode()are overridden and throw exceptions to prevent accidental damage.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCOLLECTIONS_ERROR_MESSAGEError information if somebody puts us in a Java collection.private java.nio.charset.CharsetDecoderdecoderCharacter encoding in internal buffers.(package private) java.nio.ByteBufferstemBufferByte buffer holding stem data.private java.nio.CharBufferstemCharSequenceCharacter sequence after convertingstemBufferusingdecoder.(package private) java.nio.ByteBuffertagBufferByte buffer holding tag data.private java.nio.CharBuffertagCharSequence(package private) java.nio.ByteBufferwordBufferByte buffer holding the inflected word form data.private java.lang.CharSequencewordCharSequenceInflected word form data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WordDataclone()Declare a covariant ofObject.clone()that returns a deep copy of this object.private java.lang.CharSequencecloneCharSequence(java.lang.CharSequence chs)Clone char sequences only if not immutable.booleanequals(java.lang.Object obj)java.lang.CharSequencegetStem()java.nio.ByteBuffergetStemBytes(java.nio.ByteBuffer target)Copy the stem's binary data (no charset decoding) to a custom byte buffer.java.lang.CharSequencegetTag()java.nio.ByteBuffergetTagBytes(java.nio.ByteBuffer target)Copy the tag's binary data (no charset decoding) to a custom byte buffer.java.lang.CharSequencegetWord()java.nio.ByteBuffergetWordBytes(java.nio.ByteBuffer target)Copy the inflected word's binary data (no charset decoding) to a custom byte buffer.inthashCode()java.lang.StringtoString()(package private) voidupdate(java.nio.ByteBuffer wordBuffer, java.lang.CharSequence word)
-
-
-
Field Detail
-
COLLECTIONS_ERROR_MESSAGE
private static final java.lang.String COLLECTIONS_ERROR_MESSAGE
Error information if somebody puts us in a Java collection.- See Also:
- Constant Field Values
-
decoder
private final java.nio.charset.CharsetDecoder decoder
Character encoding in internal buffers.
-
wordCharSequence
private java.lang.CharSequence wordCharSequence
Inflected word form data.
-
stemCharSequence
private java.nio.CharBuffer stemCharSequence
Character sequence after convertingstemBufferusingdecoder.
-
tagCharSequence
private java.nio.CharBuffer tagCharSequence
-
wordBuffer
java.nio.ByteBuffer wordBuffer
Byte buffer holding the inflected word form data.
-
stemBuffer
java.nio.ByteBuffer stemBuffer
Byte buffer holding stem data.
-
tagBuffer
java.nio.ByteBuffer tagBuffer
Byte buffer holding tag data.
-
-
Method Detail
-
getStemBytes
public java.nio.ByteBuffer getStemBytes(java.nio.ByteBuffer target)
Copy the stem's binary data (no charset decoding) to a custom byte buffer. The buffer is cleared prior to copying and flipped for reading upon returning from this method. If the buffer is null or not large enough to hold the result, a new buffer is allocated.- Parameters:
target- Target byte buffer to copy the stem buffer to ornullif a new buffer should be allocated.- Returns:
- Returns
targetor the new reallocated buffer.
-
getTagBytes
public java.nio.ByteBuffer getTagBytes(java.nio.ByteBuffer target)
Copy the tag's binary data (no charset decoding) to a custom byte buffer. The buffer is cleared prior to copying and flipped for reading upon returning from this method. If the buffer is null or not large enough to hold the result, a new buffer is allocated.- Parameters:
target- Target byte buffer to copy the tag buffer to ornullif a new buffer should be allocated.- Returns:
- Returns
targetor the new reallocated buffer.
-
getWordBytes
public java.nio.ByteBuffer getWordBytes(java.nio.ByteBuffer target)
Copy the inflected word's binary data (no charset decoding) to a custom byte buffer. The buffer is cleared prior to copying and flipped for reading upon returning from this method. If the buffer is null or not large enough to hold the result, a new buffer is allocated.- Parameters:
target- Target byte buffer to copy the word buffer to ornullif a new buffer should be allocated.- Returns:
- Returns
targetor the new reallocated buffer.
-
getTag
public java.lang.CharSequence getTag()
- Returns:
- Return tag data decoded to a character sequence or
nullif no associated tag data exists.
-
getStem
public java.lang.CharSequence getStem()
- Returns:
- Return stem data decoded to a character sequence or
nullif no associated stem data exists.
-
getWord
public java.lang.CharSequence getWord()
- Returns:
- Return inflected word form data. Usually the parameter passed to
DictionaryLookup.lookup(CharSequence).
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clone
public WordData clone()
Declare a covariant ofObject.clone()that returns a deep copy of this object. The content of all internal buffers is copied.- Overrides:
clonein classjava.lang.Object
-
cloneCharSequence
private java.lang.CharSequence cloneCharSequence(java.lang.CharSequence chs)
Clone char sequences only if not immutable.
-
update
void update(java.nio.ByteBuffer wordBuffer, java.lang.CharSequence word)
-
-