All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.almworks.jira.structure.util.ResourcedText Maven / Gradle / Ivy

There is a newer version: 17.25.3
Show newest version
package com.almworks.jira.structure.util;

import com.atlassian.jira.util.I18nHelper;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Element;

/**
 * 

A utility class to handle elements of module configuration (from atlassian-plugin.xml) that * specify a localizable string in the following format:

*
 *   <tagName key="some.i18n.key">non-localizable text</tagName>
 * 
* * @author Igor Sereda */ public class ResourcedText { public static final ResourcedText EMPTY_TEXT = new ResourcedText(null, null); private final String myKey; private final String myText; public ResourcedText(String key, String text) { myKey = key; myText = text; } public boolean isEmpty() { return myKey == null && myText == null; } public static ResourcedText configuredText(Element parentElement, String name) { String key = null, text = null; Element e = parentElement.element(name); if (e != null) { text = e.getTextTrim(); key = e.attributeValue("key"); } return new ResourcedText(key, text); } public String getText(I18nHelper i18n) { String r = myText; if (myKey != null) { String t = i18n.getText(myKey); if (t != null && (r == null || !t.equals(myKey))) r = t; } return StringUtils.defaultString(r); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy