本文整理汇总了Java中com.helger.commons.string.StringHelper类的典型用法代码示例。如果您正苦于以下问题:Java StringHelper类的具体用法?Java StringHelper怎么用?Java StringHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringHelper类属于com.helger.commons.string包,在下文中一共展示了StringHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerAndCheck
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
/**
* Check if the passed message ID was already handled.
*
* @param sMessageID
* Message ID to check. May be <code>null</code>.
* @param sProfileID
* Active AS4 profile ID. May be used to define the PMode further. May
* be <code>null</code>.
* @param sPModeID
* Active AS4 PMode ID. May be <code>null</code>.
* @return {@link EContinue#CONTINUE} to continue
*/
@Nonnull
public EContinue registerAndCheck (@Nullable final String sMessageID,
@Nullable final String sProfileID,
@Nullable final String sPModeID)
{
if (StringHelper.hasNoText (sMessageID))
{
// No message ID present - don't check for duplication
return EContinue.CONTINUE;
}
final AS4DuplicateItem aItem = new AS4DuplicateItem (sMessageID, sProfileID, sPModeID);
try
{
m_aRWLock.writeLocked ( () -> {
internalCreateItem (aItem);
});
}
catch (final IllegalArgumentException ex)
{
// ID already in use
return EContinue.BREAK;
}
return EContinue.CONTINUE;
}
示例2: PModeParty
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
public PModeParty (@Nullable final String sIDType,
@Nonnull @Nonempty final String sIDValue,
@Nonnull @Nonempty final String sRole,
@Nullable final String sUserName,
@Nullable final String sPassword)
{
m_sIDType = sIDType;
m_sIDValue = ValueEnforcer.notEmpty (sIDValue, "IDValue");
m_sRole = ValueEnforcer.notEmpty (sRole, "Role");
m_sUserName = sUserName;
m_sPassword = sPassword;
m_sID = m_sIDValue;
if (!StringHelper.getNotNull (m_sIDType).equals (""))
{
m_sID = m_sIDType + ":" + m_sIDValue;
}
}
示例3: _createPropsFromFile
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
@Nonnull
private static CryptoProperties _createPropsFromFile (@Nullable final String sCryptoPropertiesPath)
{
CryptoProperties aCryptoProps;
if (StringHelper.hasNoText (sCryptoPropertiesPath))
{
// Uses crypto.properties => needs exact name crypto.properties
aCryptoProps = new CryptoProperties (new ClassPathResource ("private-crypto.properties"));
if (!aCryptoProps.isRead ())
aCryptoProps = new CryptoProperties (new ClassPathResource ("crypto.properties"));
}
else
{
aCryptoProps = new CryptoProperties (new ClassPathResource (sCryptoPropertiesPath));
}
return aCryptoProps;
}
示例4: createEbms3MessageInfo
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
/**
* Create a new message info.
*
* @param sMessageID
* The message ID. May neither be <code>null</code> nor empty.
* @param sRefToMessageID
* to set the reference to the previous message needed for two way
* exchanges
* @return Never <code>null</code>.
*/
@Nonnull
public static Ebms3MessageInfo createEbms3MessageInfo (@Nonnull @Nonempty final String sMessageID,
@Nullable final String sRefToMessageID)
{
ValueEnforcer.notEmpty (sMessageID, "MessageID");
final Ebms3MessageInfo aMessageInfo = new Ebms3MessageInfo ();
aMessageInfo.setMessageId (sMessageID);
if (StringHelper.hasText (sRefToMessageID))
aMessageInfo.setRefToMessageId (sRefToMessageID);
aMessageInfo.setTimestamp (PDTXMLConverter.getXMLCalendarNowUTC ());
return aMessageInfo;
}
示例5: _checkPropertiesOrignalSenderAndFinalRecipient
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
/**
* Checks the mandatory properties OriginalSender and FinalRecipient if those
* two are set.
*
* @param aPropertyList
* the property list that should be checked for the two specific ones
* @throws BadRequestException
* on error
*/
private static void _checkPropertiesOrignalSenderAndFinalRecipient (@Nonnull final List <Ebms3Property> aPropertyList) throws BadRequestException
{
String sOriginalSenderC1 = null;
String sFinalRecipientC4 = null;
for (final Ebms3Property sProperty : aPropertyList)
{
if (sProperty.getName ().equals (CAS4.ORIGINAL_SENDER))
sOriginalSenderC1 = sProperty.getValue ();
else
if (sProperty.getName ().equals (CAS4.FINAL_RECIPIENT))
sFinalRecipientC4 = sProperty.getValue ();
}
if (StringHelper.hasNoText (sOriginalSenderC1))
throw new BadRequestException (CAS4.ORIGINAL_SENDER + " property is empty or not existant but mandatory");
if (StringHelper.hasNoText (sFinalRecipientC4))
throw new BadRequestException (CAS4.FINAL_RECIPIENT + " property is empty or not existant but mandatory");
}
示例6: fillBody
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
@Override
protected void fillBody (@Nonnull final ISimpleWebExecutionContext aSWEC,
@Nonnull final HCHtml aHtml) throws ForcedRedirectException
{
final IRequestWebScopeWithoutResponse aRequestScope = aSWEC.getRequestScope ();
final Locale aDisplayLocale = aSWEC.getDisplayLocale ();
final IMenuItemPage aMenuItem = RequestSettings.getMenuItem (aRequestScope);
final LayoutExecutionContext aLEC = new LayoutExecutionContext (aSWEC, aMenuItem);
final HCHead aHead = aHtml.head ();
final HCBody aBody = aHtml.body ();
// Add menu item in page title
aHead.setPageTitle (StringHelper.getConcatenatedOnDemand (AppCommonUI.getApplicationTitle (),
" - ",
aMenuItem.getDisplayText (aDisplayLocale)));
final IHCNode aNode = m_aFactory.apply (aLEC);
aBody.addChild (aNode);
}
示例7: _initCertificateIssuers
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
private static void _initCertificateIssuers ()
{
// Get the certificate issuer we need
final String sIssuerToSearch = PDServerConfiguration.getClientCertIssuer ();
if (StringHelper.hasNoText (sIssuerToSearch))
throw new InitializationException ("The configuration file is missing the entry for the client certificate issuer");
// Throws a runtime exception on syntax error anyway :)
s_aSearchIssuers.add (new X500Principal (sIssuerToSearch));
// Optional alternative issuer
final String sIssuerToSearchAlternative = PDServerConfiguration.getClientCertIssuerAlternative ();
if (StringHelper.hasText (sIssuerToSearchAlternative))
{
// Throws a runtime exception on syntax error anyway :)
s_aSearchIssuers.add (new X500Principal (sIssuerToSearchAlternative));
}
s_aLogger.info ("The following client certificate issuer(s) are valid: " + s_aSearchIssuers);
}
示例8: encode
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
public void encode (@Nonnull @WillNotClose final InputStream aDecodedIS,
@Nonnull @WillNotClose final OutputStream aOS)
{
ValueEnforcer.notNull (aDecodedIS, "DecodedInputStream");
ValueEnforcer.notNull (aOS, "OutputStream");
try
{
int nByte;
while ((nByte = aDecodedIS.read ()) != -1)
{
aOS.write (StringHelper.getHexChar ((nByte & 0xf0) >> 4));
aOS.write (StringHelper.getHexChar (nByte & 0x0f));
}
}
catch (final IOException ex)
{
throw new EncodeException ("Failed to encode Base16", ex);
}
}
示例9: getLocalTimeFromString
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
@Nullable
public static LocalTime getLocalTimeFromString (@Nullable final String sValue, @Nonnull final DateTimeFormatter aDF)
{
ValueEnforcer.notNull (aDF, "DateTimeFormatter");
if (StringHelper.hasText (sValue))
try
{
return aDF.parse (sValue, LocalTime::from);
}
catch (final DateTimeParseException ex)
{
_onParseException ("LocalTime", sValue, aDF, ex);
}
return null;
}
示例10: getIndentOuter
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
@Nonnull
public EXMLSerializeIndent getIndentOuter (@Nullable final String sParentNamespaceURI,
@Nullable final String sParentTagName,
@Nullable final String sNamespaceURI,
@Nonnull final String sTagName,
@Nullable final Map <QName, String> aAttrs,
final boolean bHasChildren,
@Nonnull final EXMLSerializeIndent eDefaultIndent)
{
if (StringHelper.hasText (sParentTagName) && _isPreOrCode (sParentTagName))
{
// Don't indent or align
return EXMLSerializeIndent.NONE;
}
// Always use the default
return eDefaultIndent;
}
示例11: onXMLDeclaration
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
/**
* At the very beginning of the document (XML declaration).
*
* @param eXMLVersion
* The XML version to use. If <code>null</code> is passed,
* {@link EXMLVersion#XML_10} will be used.
* @param sEncoding
* The encoding to be used for this document. It may be
* <code>null</code> but it is strongly recommended to write a correct
* charset.
* @param bStandalone
* if <code>true</code> this is a standalone XML document without a
* connection to an existing DTD or XML schema
*/
public void onXMLDeclaration (@Nullable final EXMLVersion eXMLVersion,
@Nullable final String sEncoding,
final boolean bStandalone)
{
if (eXMLVersion != null)
{
// Maybe switch from 1.0 to 1.1 or vice versa at the very beginning of the
// document
m_eXMLVersion = EXMLSerializeVersion.getFromXMLVersionOrThrow (eXMLVersion);
}
_append (PI_START)._append ("xml version=")._appendAttrValue (m_eXMLVersion.getXMLVersionString ());
if (StringHelper.hasText (sEncoding))
_append (" encoding=")._appendAttrValue (sEncoding);
if (bStandalone)
_append (" standalone=")._appendAttrValue ("yes");
_append (PI_END);
newLine ();
}
示例12: AuthToken
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
public AuthToken (@Nonnull final IAuthIdentification aIdentification, @Nonnegative final int nExpirationSeconds)
{
ValueEnforcer.notNull (aIdentification, "Identification");
ValueEnforcer.isGE0 (nExpirationSeconds, "ExpirationSeconds");
// create new ID
m_sID = AuthTokenIDGenerator.generateNewTokenID ();
if (StringHelper.hasNoText (m_sID))
throw new IllegalStateException ("Failed to create token ID");
m_aIdentification = aIdentification;
m_aCreationDT = PDTFactory.getCurrentLocalDateTime ();
m_aLastAccessDT = m_aCreationDT;
m_nExpirationSeconds = nExpirationSeconds;
m_bExpired = false;
}
示例13: convertToMicroElement
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
@Nonnull
public IMicroElement convertToMicroElement (@Nonnull final PostalAddress aAddress,
@Nullable final String sNamespaceURI,
@Nonnull final String sTagName)
{
final IMicroElement eAddress = new MicroElement (sNamespaceURI, sTagName);
if (aAddress.getType () != null)
eAddress.setAttribute (ATTR_TYPE, aAddress.getType ().getID ());
if (StringHelper.hasText (aAddress.getCountry ()))
eAddress.setAttribute (ATTR_COUNTRY, aAddress.getCountry ());
if (StringHelper.hasText (aAddress.getState ()))
eAddress.setAttribute (ATTR_STATE, aAddress.getState ());
if (StringHelper.hasText (aAddress.getPostalCode ()))
eAddress.setAttribute (ATTR_POSTALCODE, aAddress.getPostalCode ());
if (StringHelper.hasText (aAddress.getCity ()))
eAddress.setAttribute (ATTR_CITY, aAddress.getCity ());
if (StringHelper.hasText (aAddress.getStreet ()))
eAddress.setAttribute (ATTR_STREET, aAddress.getStreet ());
if (StringHelper.hasText (aAddress.getBuildingNumber ()))
eAddress.setAttribute (ATTR_BUILDINGNUMBER, aAddress.getBuildingNumber ());
if (StringHelper.hasText (aAddress.getPostOfficeBox ()))
eAddress.setAttribute (ATTR_POBOX, aAddress.getPostOfficeBox ());
if (StringHelper.hasText (aAddress.getCareOf ()))
eAddress.setAttribute (ATTR_CARE_OF, aAddress.getCareOf ());
return eAddress;
}
示例14: getLocalDateFromString
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
@Nullable
public static LocalDate getLocalDateFromString (@Nullable final String sValue, @Nonnull final DateTimeFormatter aDF)
{
ValueEnforcer.notNull (aDF, "DateTimeFormatter");
if (StringHelper.hasText (sValue))
try
{
return aDF.parse (sValue, LocalDate::from);
}
catch (final DateTimeParseException ex)
{
_onParseException ("LocalDate", sValue, aDF, ex);
}
return null;
}
示例15: testCurrencyNoSymbol
import com.helger.commons.string.StringHelper; //导入依赖的package包/类
@Test
public void testCurrencyNoSymbol ()
{
/*
* You could remove the currency symbol placeholder ('¤' or '\u00A4') from
* the pattern and then create a number format with this pattern. Something
* like the following:
*/
final Locale aLocale = LocaleCache.getInstance ().getLocale ("fr");
NumberFormat curFormat = NumberFormat.getCurrencyInstance (aLocale);
assertTrue (curFormat instanceof DecimalFormat);
final String pattern = ((DecimalFormat) curFormat).toPattern ();
assertEquals ("#,##0.00 \u00A4", pattern);
final String patternWithoutCurSym = StringHelper.removeAll (pattern, '\u00A4');
assertEquals ("#,##0.00 ", patternWithoutCurSym);
curFormat = new DecimalFormat (patternWithoutCurSym,
DecimalFormatSymbols.getInstance (CGlobal.LOCALE_FIXED_NUMBER_FORMAT));
assertEquals ("3.12 ", curFormat.format (3.1234));
}