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
_langId
protected String
_langLabel
protected 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 boolean
equals(Object other)
String
evaluate(ExpressionContext ctxt)
Evaluates the value expression in a given context, returns a Wikibase value suitable to be the target of a claim.String
getLabel()
String
getLang()
int
hashCode()
static String
normalizeLanguageCode(String lang)
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).void
validate(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:WbExpression
Check that this expression is fully formed and ready to be evaluated.- Specified by:
validate
in 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:WbExpression
Evaluates 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:
evaluate
in 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
-
-