Package org.openrefine.wikibase.schema
Class WbLanguageConstant
- java.lang.Object
-
- org.openrefine.wikibase.schema.WbLanguageConstant
-
- All Implemented Interfaces:
WbExpression<String>
public class WbLanguageConstant extends Object implements WbExpression<String>
A constant that represents a Wikimedia language code.- Author:
- Antonin Delpeuch
-
-
Field Summary
Fields Modifier and Type Field Description protected String_langIdprotected String_langLabelprotected String_origLangId
-
Constructor Summary
Constructors Constructor Description WbLanguageConstant(String langId, String langLabel)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Stringevaluate(ExpressionContext ctxt)Evaluates the value expression in a given context, returns a Wikibase value suitable to be the target of a claim.StringgetLabel()StringgetLang()inthashCode()static StringnormalizeLanguageCode(String lang)static StringnormalizeLanguageCode(String lang, String mediaWikiApiEndpoint)Checks that a language code is valid and returns its preferred version (converting deprecated language codes to their better values).voidvalidate(ValidationState validation)Check that this expression is fully formed and ready to be evaluated.
-
-
-
Method Detail
-
validate
public void validate(ValidationState validation)
Description copied from interface:WbExpressionCheck that this expression is fully formed and ready to be evaluated.- Specified by:
validatein interfaceWbExpression<String>- Parameters:
validation- the state in which to log any validation errors
-
normalizeLanguageCode
public static String normalizeLanguageCode(String lang, String mediaWikiApiEndpoint)
Checks that a language code is valid and returns its preferred version (converting deprecated language codes to their better values).- Parameters:
lang- a Wikimedia language codemediaWikiApiEndpoint- the MediaWiki API endpoint of the Wikibase- Returns:
- the normalized code, or null if the code is invalid.
-
evaluate
public String evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException
Description copied from interface:WbExpressionEvaluates the value expression in a given context, returns a Wikibase value suitable to be the target of a claim. As a premise to calling that method, we assume that callingWbExpression.validate(ValidationState)did not log any error in the validation state.- Specified by:
evaluatein interfaceWbExpression<String>- Throws:
SkipSchemaExpressionException
-
getLang
public String getLang()
- Returns:
- the language code for this language
-
getLabel
public String getLabel()
- Returns:
- the name of the language in itself
-
-