Revision ae6212a2
Added by Marc Geoffroy almost 16 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/TextData.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
/** |
38 | 38 |
* This class represents information pieces expressed in one or several natural |
39 |
* languages and eventually with a format used for structuring the text.
|
|
39 |
* languages. A {@link TextFormat format} used for structuring the text may also be stated.
|
|
40 | 40 |
* <P> |
41 | 41 |
* This class corresponds partially to NaturalLanguageDescription according to |
42 | 42 |
* the SDD schema. |
... | ... | |
116 | 116 |
* Creates a new text data instance with a given text in a given particular |
117 | 117 |
* {@link Language language} and with the given text format for structuring it. |
118 | 118 |
* |
119 |
* @param text the text string containing the content of the description
|
|
119 |
* @param text the text string with the content of the description
|
|
120 | 120 |
* @param language the language in which the text string is formulated |
121 | 121 |
* @param format the text format used to structure the text string |
122 | 122 |
* @see #NewInstance() |
... | ... | |
129 | 129 |
return result; |
130 | 130 |
} |
131 | 131 |
|
132 |
/** |
|
133 |
* @return |
|
132 |
/** |
|
133 |
* Returns the multilanguage text with the content of <i>this</i> text data. |
|
134 |
* The different {@link LanguageString language strings} (texts) contained in the |
|
135 |
* multilanguage text should all have the same meaning. |
|
136 |
* |
|
137 |
* @see #getText(Language) |
|
134 | 138 |
*/ |
135 | 139 |
@OneToMany (fetch= FetchType.LAZY) |
136 | 140 |
@MapKey(name="language") |
... | ... | |
140 | 144 |
initTextSet(); |
141 | 145 |
return multiLanguageText; |
142 | 146 |
} |
147 |
/** |
|
148 |
* @see #getMultilanguageText() |
|
149 |
*/ |
|
143 | 150 |
protected void setMultilanguageText(Map<Language, LanguageString> texts) { |
144 | 151 |
//protected void setMultilanguageText(MultilanguageText texts) { |
145 | 152 |
this.multiLanguageText = texts; |
146 | 153 |
} |
154 |
/** |
|
155 |
* Returns the text string in the given {@link Language language} with the content |
|
156 |
* of <i>this</i> text data. |
|
157 |
* |
|
158 |
* @param language the language in which the text string looked for is formulated |
|
159 |
* @see #getMultilanguageText() |
|
160 |
*/ |
|
147 | 161 |
@Transient |
148 | 162 |
public String getText(Language language) { |
149 | 163 |
initTextSet(); |
... | ... | |
155 | 169 |
} |
156 | 170 |
} |
157 | 171 |
|
172 |
/** |
|
173 |
* Creates a {@link LanguageString language string} based on the given text string |
|
174 |
* and the given {@link Language language}, returns it and adds it to the multilanguage |
|
175 |
* text representing the content of <i>this</i> text data. |
|
176 |
* |
|
177 |
* @param text the string representing the content of the text data |
|
178 |
* in a particular language |
|
179 |
* @param language the language in which the text string is formulated |
|
180 |
* @return the language string |
|
181 |
* @see #getMultilanguageText() |
|
182 |
* @see #putText(LanguageString) |
|
183 |
*/ |
|
158 | 184 |
@Transient |
159 | 185 |
public LanguageString putText(String text, Language language) { |
160 | 186 |
initTextSet(); |
161 | 187 |
LanguageString result = this.multiLanguageText.put(language , LanguageString.NewInstance(text, language)); |
162 | 188 |
return (result == null ? null : result); |
163 | 189 |
} |
190 |
/** |
|
191 |
* Adds a translated {@link LanguageString text in a particular language} |
|
192 |
* to the multilanguage text representing the content of <i>this</i> text data. |
|
193 |
* The given language string will be returned. |
|
194 |
* |
|
195 |
* @param languageString the language string representing the content of |
|
196 |
* the text data in a particular language |
|
197 |
* @return the language string |
|
198 |
* @see #getMultilanguageText() |
|
199 |
* @see #putText(String, Language) |
|
200 |
*/ |
|
164 | 201 |
@Transient |
165 | 202 |
public LanguageString putText(LanguageString languageString) { |
166 | 203 |
initTextSet(); |
... | ... | |
172 | 209 |
return this.multiLanguageText.put(language, languageString); |
173 | 210 |
} |
174 | 211 |
} |
212 |
/** |
|
213 |
* Removes from the multilanguage representing the content of |
|
214 |
* <i>this</i> text data the one {@link LanguageString language string} |
|
215 |
* with the given {@link Language language}. Returns the removed |
|
216 |
* language string. |
|
217 |
* |
|
218 |
* @param language the language in which the language string to be removed |
|
219 |
* has been formulated |
|
220 |
* @return the language string associated with the given language |
|
221 |
* @see #getMultilanguageText() |
|
222 |
*/ |
|
175 | 223 |
public LanguageString removeText(Language language) { |
176 | 224 |
initTextSet(); |
177 | 225 |
return this.multiLanguageText.remove(language); |
... | ... | |
183 | 231 |
} |
184 | 232 |
} |
185 | 233 |
|
234 |
/** |
|
235 |
* Returns the number of {@link Language languages} in which the content |
|
236 |
* of <i>this</i> text data has been formulated. |
|
237 |
* |
|
238 |
* @see #getMultilanguageText() |
|
239 |
*/ |
|
186 | 240 |
public int countLanguages(){ |
187 | 241 |
initTextSet(); |
188 | 242 |
return multiLanguageText.size(); |
189 | 243 |
} |
190 | 244 |
|
191 | 245 |
|
246 |
/** |
|
247 |
* Returns the {@link TextFormat format} used for structuring the text representing |
|
248 |
* the content of <i>this</i> text data. |
|
249 |
* |
|
250 |
* @see #getMultilanguageText() |
|
251 |
*/ |
|
192 | 252 |
@ManyToOne |
193 | 253 |
public TextFormat getFormat() { |
194 | 254 |
return format; |
195 | 255 |
} |
256 |
/** |
|
257 |
* @see #getFormat() |
|
258 |
*/ |
|
196 | 259 |
public void setFormat(TextFormat format) { |
197 | 260 |
this.format = format; |
198 | 261 |
} |
Also available in: Unified diff
Only documentation