Package com.yahoo.prelude.hitfield
Class HitField
- java.lang.Object
-
- com.yahoo.prelude.hitfield.HitField
-
public class HitField extends java.lang.Object
Represents a tokenized string field in a Hit. The original raw content and the field name cannot be modified. But the tokenized version can be retrieved and set.- Author:
- Lars Christian Jensen
-
-
Constructor Summary
Constructors Constructor Description HitField(java.lang.String fieldName, XMLString content)
HitField(java.lang.String fieldName, XMLString content, boolean cjk)
Creates a hit fieldHitField(java.lang.String fieldName, java.lang.String content)
HitField(java.lang.String fieldName, java.lang.String content, boolean cjk)
HitField(java.lang.String fieldname, java.lang.String content, boolean cjk, boolean xmlProperty)
Creates a hit field
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
bareContent(boolean XMLQuote, boolean inAttribute)
Returns the content of the field, stripped of markupjava.lang.String
getContent()
Returns the content of this fieldjava.lang.String
getContent(java.lang.String boldOpenTag, java.lang.String boldCloseTag, java.lang.String separatorTag)
Returns the content of this field, using the arguments as bolding tagsjava.lang.String
getName()
java.lang.Object
getOriginal()
Fetch the object which (the String representation of) this HitField was built from.java.lang.String
getRawContent()
java.util.List<FieldPart>
getTokenizedContent()
Get a list representation of the tokens in the content.java.util.ListIterator<FieldPart>
listIterator()
Return an iterator for the tokens, delimiters and markup elements of the field.void
markDirty()
java.lang.String
quotedContent(boolean inAttribute)
java.lang.String
quotedContent(java.lang.String boldOpenTag, java.lang.String boldCloseTag, java.lang.String separatorTag, boolean inAttribute)
Returns the content of this field, using the arguments as bolding tags, as an XML stringvoid
setOriginal(java.lang.Object original)
Optionally set the object which this HitField should represent.void
setTokenizedContent(java.util.List<FieldPart> list)
Only FieldPart objects must be present in the list.java.util.ListIterator<FieldPart>
tokenIterator()
Return an iterator over the tokens of this fieldjava.lang.String
toString()
-
-
-
Constructor Detail
-
HitField
public HitField(java.lang.String fieldName, java.lang.String content)
-
HitField
public HitField(java.lang.String fieldName, XMLString content)
-
HitField
public HitField(java.lang.String fieldName, java.lang.String content, boolean cjk)
-
HitField
public HitField(java.lang.String fieldName, XMLString content, boolean cjk)
Creates a hit field- Parameters:
cjk
- true if the content is CJK text
-
HitField
public HitField(java.lang.String fieldname, java.lang.String content, boolean cjk, boolean xmlProperty)
Creates a hit field- Parameters:
fieldname
- The field namecontent
- The field contentcjk
- true if the content is CJK textxmlProperty
- true if this should not quote XML syntax
-
-
Method Detail
-
getName
public java.lang.String getName()
-
getRawContent
public java.lang.String getRawContent()
-
getTokenizedContent
public java.util.List<FieldPart> getTokenizedContent()
Get a list representation of the tokens in the content. This is only a copy, changes here will not affect the HitField.- Returns:
- a list containing the content in tokenized form.
-
listIterator
public java.util.ListIterator<FieldPart> listIterator()
Return an iterator for the tokens, delimiters and markup elements of the field.
-
tokenIterator
public java.util.ListIterator<FieldPart> tokenIterator()
Return an iterator over the tokens of this field
-
setTokenizedContent
public void setTokenizedContent(java.util.List<FieldPart> list)
Only FieldPart objects must be present in the list.- Parameters:
list
- contains the new content of this HitField in tokenized form.
-
getContent
public java.lang.String getContent()
Returns the content of this field
-
getContent
public java.lang.String getContent(java.lang.String boldOpenTag, java.lang.String boldCloseTag, java.lang.String separatorTag)
Returns the content of this field, using the arguments as bolding tags
-
markDirty
public void markDirty()
-
quotedContent
public java.lang.String quotedContent(boolean inAttribute)
- Parameters:
inAttribute
- whether to quote quotation marks- Returns:
- the content of this field as an XML string
-
quotedContent
public java.lang.String quotedContent(java.lang.String boldOpenTag, java.lang.String boldCloseTag, java.lang.String separatorTag, boolean inAttribute)
Returns the content of this field, using the arguments as bolding tags, as an XML string
-
bareContent
public java.lang.String bareContent(boolean XMLQuote, boolean inAttribute)
Returns the content of the field, stripped of markup
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getOriginal
public java.lang.Object getOriginal()
Fetch the object which (the String representation of) this HitField was built from. This may be null as setting the original is optional.
-
setOriginal
public void setOriginal(java.lang.Object original)
Optionally set the object which this HitField should represent.
-
-