本文整理汇总了Java中com.helger.commons.string.StringHelper.getNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java StringHelper.getNotNull方法的具体用法?Java StringHelper.getNotNull怎么用?Java StringHelper.getNotNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.string.StringHelper
的用法示例。
在下文中一共展示了StringHelper.getNotNull方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocationAsString
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Nonnull
@Nonempty
public String getLocationAsString ()
{
final String sFirst = getFirstTokenLocationAsString ();
final String sLast = getLastTokenLocationAsString ();
return StringHelper.getNotNull (sFirst, "") + "-" + StringHelper.getNotNull (sLast, "");
}
示例2: getElementNamespacePrefixToUse
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Nullable
public String getElementNamespacePrefixToUse (@Nonnull final String sNamespaceURI,
final boolean bIsRootElement,
@Nonnull final Map <QName, String> aAttrMap)
{
final String sDefaultNamespaceURI = StringHelper.getNotNull (_getDefaultNamespaceURI ());
if (sNamespaceURI.equals (sDefaultNamespaceURI))
{
// It's the default namespace
return null;
}
String sNSPrefix = _getUsedPrefixOfNamespace (sNamespaceURI);
// Do we need to create a prefix?
if (sNSPrefix == null && (!bIsRootElement || sNamespaceURI.length () > 0))
{
// Ensure to use the correct prefix (namespace context)
sNSPrefix = _getMappedPrefix (sNamespaceURI);
// Do not create a prefix for the root element
if (sNSPrefix == null && !bIsRootElement)
sNSPrefix = _createUniquePrefix ();
// Add and remember the attribute
aAttrMap.put (XMLHelper.getXMLNSAttrQName (sNSPrefix), sNamespaceURI);
addNamespaceMapping (sNSPrefix, sNamespaceURI);
}
return sNSPrefix;
}
示例3: getLocale
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
/**
* Get the {@link Locale} object matching the given locale string
*
* @param sLanguage
* The language to use. May be <code>null</code> or empty.
* @param sCountry
* Optional country to use. May be <code>null</code>.
* @param sVariant
* Optional variant. May be <code>null</code>.
* @return <code>null</code> if all the passed parameters are
* <code>null</code> or empty
*/
@Nullable
public Locale getLocale (@Nullable final String sLanguage,
@Nullable final String sCountry,
@Nullable final String sVariant)
{
final String sRealLanguage = StringHelper.getNotNull (LocaleHelper.getValidLanguageCode (sLanguage));
final String sRealCountry = StringHelper.getNotNull (LocaleHelper.getValidCountryCode (sCountry));
final String sRealVariant = StringHelper.getNotNull (sVariant);
final String sLocaleKey = _buildLocaleString (sRealLanguage, sRealCountry, sRealVariant);
if (sLocaleKey.length () == 0)
return null;
// try to resolve locale
Locale aLocale = m_aRWLock.readLocked ( () -> m_aLocales.get (sLocaleKey));
if (aLocale == null)
{
// Try fetching again in writeLock
// not yet in cache, create a new one
// -> may lead to illegal locales, but simpler than the error handling
// for all the possible illegal values
aLocale = m_aRWLock.writeLocked ( () -> m_aLocales.computeIfAbsent (sLocaleKey,
k -> new Locale (sRealLanguage,
sRealCountry,
sRealVariant)));
}
return aLocale;
}
示例4: _createLocaleKey
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Nonnull
private static String _createLocaleKey (@Nullable final String sLanguage,
@Nullable final String sCountry,
@Nullable final String sVariant)
{
final String sRealLanguage = StringHelper.getNotNull (LocaleHelper.getValidLanguageCode (sLanguage));
final String sRealCountry = StringHelper.getNotNull (LocaleHelper.getValidCountryCode (sCountry));
final String sRealVariant = StringHelper.getNotNull (sVariant);
return _buildLocaleString (sRealLanguage, sRealCountry, sRealVariant);
}
示例5: handleRequest
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
public void handleRequest (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope,
@Nonnull final UnifiedResponse aUnifiedResponse) throws Exception
{
// http://127.0.0.1:8080/participant -> null
// http://127.0.0.1:8080/participant/ -> "/"
// http://127.0.0.1:8080/participant/x -> "/x"
final String sPathInfo = StringHelper.getNotNull (aRequestScope.getPathInfo (), "");
final ICommonsList <String> aParts = StringHelper.getExploded ('/', sPathInfo.substring (1));
IParticipantIdentifier aPI = null;
if (aParts.isNotEmpty ())
{
final String sID = aParts.get (0);
aPI = PDMetaManager.getIdentifierFactory ().parseParticipantIdentifier (sID);
if (aPI == null)
{
// Maybe the scheme is missing
// Check if there is a second part as in
// /participant/iso6523-actorid-upis/9915:test
if (aParts.size () >= 2)
{
final String sScheme = sID;
final String sValue = aParts.get (1);
aPI = PDMetaManager.getIdentifierFactory ().createParticipantIdentifier (sScheme, sValue);
}
}
if (aPI == null)
{
// Still failure - try PEPPOL default scheme
aPI = PDMetaManager.getIdentifierFactory ()
.createParticipantIdentifier (PeppolIdentifierFactory.INSTANCE.getDefaultParticipantIdentifierScheme (),
sID);
}
}
if (aPI == null)
{
s_aLogger.error ("Failed to resolve path '" + sPathInfo + "' to a participant ID!");
aUnifiedResponse.setStatus (HttpServletResponse.SC_NOT_FOUND);
return;
}
// Redirect to search result page
final SimpleURL aTarget = RequestParameterManager.getInstance ()
.getLinkToMenuItem (aRequestScope,
AppCommonUI.DEFAULT_LOCALE,
CMenuPublic.MENU_SEARCH_SIMPLE)
.add (CPageParam.PARAM_ACTION, CPageParam.ACTION_VIEW)
.add (PagePublicSearchSimple.FIELD_QUERY, aPI.getURIEncoded ())
.add (PagePublicSearchSimple.FIELD_PARTICIPANT_ID,
aPI.getURIEncoded ());
aUnifiedResponse.setRedirect (aTarget);
}
示例6: JAXBDocumentType
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
/**
* Constructor
*
* @param aClass
* The JAXB generated class of the root element. May not be
* <code>null</code>. This class must have the <code>@XmlType</code>
* annotation and the package the class resides in must have the
* <code>@XmlSchema</code> annotation with a non-null
* <code>namespace</code> property!
* @param aXSDPaths
* The classpath relative paths to the XML Schema. May not be
* <code>null</code> but maybe empty. If the main XSD imports another
* XSD, the imported XSD must come first in the list. So the XSDs
* without any dependencies must come first!
* @param aTypeToElementNameMapper
* An optional function to determine element name from type name. E.g.
* in UBL the type has an additional "Type" at the end that may not
* occur here. SBDH in contrary does not have such a suffix. May be
* <code>null</code> indicating that no name mapping is necessary.
*/
public JAXBDocumentType (@Nonnull final Class <?> aClass,
@Nullable final List <String> aXSDPaths,
@Nullable final Function <? super String, ? extends String> aTypeToElementNameMapper)
{
ValueEnforcer.notNull (aClass, "Class");
ValueEnforcer.noNullValue (aXSDPaths, "XSDPaths");
// Check whether it is an @XmlType class
final XmlType aXmlType = aClass.getAnnotation (XmlType.class);
if (aXmlType == null)
throw new IllegalArgumentException ("The passed class does not have an @XmlType annotation!");
// Get the package of the passed Class
final Package aPackage = aClass.getPackage ();
// The package must have the annotation "XmlSchema" with the corresponding
// namespace it supports (maybe empty but not null). If the base XSD does
// not contain
// any namespace URI, the XMLSchema annotation might be missing!
final XmlSchema aXmlSchema = aPackage.getAnnotation (XmlSchema.class);
if (aXmlSchema != null && aXmlSchema.namespace () == null)
throw new IllegalArgumentException ("The package '" +
aPackage.getName () +
"' has no namespace URI in the @XmlSchema annotation!");
// Depending on the generation mode, the class may have the @XmlRootElement
// annotation or not. If it is present, use the namespace URI and the local
// name from it, else try to deduce the name from the type.
String sNamespaceURI;
String sLocalName;
final XmlRootElement aRootElement = aClass.getAnnotation (XmlRootElement.class);
if (aRootElement != null)
{
sNamespaceURI = aRootElement.namespace ();
if ("##default".equals (sNamespaceURI) && aXmlSchema != null)
sNamespaceURI = aXmlSchema.namespace ();
sLocalName = aRootElement.name ();
if ("##default".equals (sLocalName))
sLocalName = aXmlType.name ();
}
else
{
// Hack: build the element name from the type name
if (aXmlSchema != null)
sNamespaceURI = aXmlSchema.namespace ();
else
sNamespaceURI = null;
sLocalName = aXmlType.name ();
}
if (aTypeToElementNameMapper != null)
sLocalName = aTypeToElementNameMapper.apply (sLocalName);
if (StringHelper.hasNoText (sLocalName))
throw new IllegalArgumentException ("Failed to determine the local name of the element to be created!");
m_aClass = aClass;
m_aXSDPaths = new CommonsArrayList <> (aXSDPaths);
m_sNamespaceURI = StringHelper.getNotNull (sNamespaceURI);
m_sLocalName = sLocalName;
}
示例7: getAttributeNamespacePrefixToUse
import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Nullable
public String getAttributeNamespacePrefixToUse (@Nonnull final String sNamespaceURI,
@Nonnull final String sName,
@Nonnull final String sValue,
@Nonnull final Map <QName, String> aAttrMap)
{
final String sDefaultNamespaceURI = StringHelper.getNotNull (_getDefaultNamespaceURI ());
if (sNamespaceURI.equals (sDefaultNamespaceURI))
{
// It's the default namespace
return null;
}
String sNSPrefix = _getUsedPrefixOfNamespace (sNamespaceURI);
// Do we need to create a prefix?
if (sNSPrefix == null)
{
if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals (sNamespaceURI))
{
// It is an "xmlns:xyz" attribute
sNSPrefix = sName;
// Don't emit "xmlns:xmlns"
if (!XMLConstants.XMLNS_ATTRIBUTE.equals (sName))
{
// Add and remember the attribute
aAttrMap.put (XMLHelper.getXMLNSAttrQName (sNSPrefix), sValue);
}
addNamespaceMapping (sNSPrefix, sValue);
}
else
{
// Ensure to use the correct prefix (namespace context)
sNSPrefix = _getMappedPrefix (sNamespaceURI);
// Do not create a prefix for the root element
if (sNSPrefix == null)
{
if (sNamespaceURI.length () == 0)
{
// Don't create a namespace mapping for attributes without a
// namespace URI
return null;
}
sNSPrefix = _createUniquePrefix ();
}
// Don't emit "xmlns:xml"
if (!XMLConstants.XML_NS_PREFIX.equals (sNSPrefix))
{
// Add and remember the attribute
aAttrMap.put (XMLHelper.getXMLNSAttrQName (sNSPrefix), sNamespaceURI);
}
addNamespaceMapping (sNSPrefix, sNamespaceURI);
}
}
return sNSPrefix;
}