当前位置: 首页>>代码示例>>Java>>正文


Java StringHelper.trimStart方法代码示例

本文整理汇总了Java中com.helger.commons.string.StringHelper.trimStart方法的典型用法代码示例。如果您正苦于以下问题:Java StringHelper.trimStart方法的具体用法?Java StringHelper.trimStart怎么用?Java StringHelper.trimStart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.helger.commons.string.StringHelper的用法示例。


在下文中一共展示了StringHelper.trimStart方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRelativeToParentDirectory

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
/**
 * Tries to express the passed file path relative to the passed parent
 * directory. If the parent directory is null or not actually a parent of the
 * passed file, the passed file name will be returned unchanged.
 *
 * @param aFile
 *        The file which is to be described relatively. May not be
 *        <code>null</code>.
 * @param aParentDirectory
 *        The parent directory of the file to which the relative path
 *        expression will relate to. May be <code>null</code>.
 * @return The relative path or the unchanged absolute file path using Unix
 *         path separators instead of Operating System dependent separator. Or
 *         <code>null</code> if the passed file contains a path traversal at
 *         the beginning
 * @see #getCleanPath(File)
 * @see #startsWithPathSeparatorChar(CharSequence)
 */
@Nullable
public static String getRelativeToParentDirectory (@Nonnull final File aFile, @Nullable final File aParentDirectory)
{
  ValueEnforcer.notNull (aFile, "File");

  final String sCleanedFile = getCleanPath (aFile);
  if (aParentDirectory == null)
    return sCleanedFile;

  String sRelative = StringHelper.trimStart (sCleanedFile, getCleanPath (aParentDirectory));
  if (sRelative.equals (sCleanedFile))
  {
    // The passed file contains a path traversal!
    return null;
  }

  if (startsWithPathSeparatorChar (sRelative))
  {
    // Ignore any leading path separator char
    sRelative = sRelative.substring (1);
  }
  return sRelative;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:42,代码来源:FilenameHelper.java

示例2: apply

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Override
public String apply (@Nullable final Object aValue)
{
  String sValue = getValueAsString (aValue);
  // strip prefix and suffix
  if (m_sPrefix.length () > 0)
    sValue = StringHelper.trimStart (sValue, m_sPrefix);
  if (m_sSuffix.length () > 0)
    sValue = StringHelper.trimEnd (sValue, m_sSuffix);
  return sValue;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:12,代码来源:FormatterStringSkipPrefixAndSuffix.java

示例3: getWithoutPEMHeader

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
/**
 * Remove any eventually preceding {@value #BEGIN_CERTIFICATE} and succeeding
 * {@value #END_CERTIFICATE} values from the passed certificate string.
 * Additionally all whitespaces of the string are removed.
 *
 * @param sCertificate
 *        The source certificate string. May be <code>null</code>.
 * @return <code>null</code> if the input string is <code>null</code> or
 *         empty, the stripped down string otherwise.
 */
@Nullable
public static String getWithoutPEMHeader (@Nullable final String sCertificate)
{
  if (StringHelper.hasNoText (sCertificate))
    return null;

  // Remove special begin and end stuff
  String sRealCertificate = sCertificate.trim ();

  /**
   * Handle certain misconfiguration issues. E.g. for 9906:testconsip on
   *
   * <pre>
   * http://b-c073e04afb234f70e74d3444ba3f8eaa.iso6523-actorid-upis.acc.edelivery.tech.ec.europa.eu/iso6523-actorid-upis%3A%3A9906%3Atestconsip/services/busdox-docid-qns%3A%3Aurn%3Aoasis%3Anames%3Aspecification%3Aubl%3Aschema%3Axsd%3AOrder-2%3A%3AOrder%23%23urn%3Awww.cenbii.eu%3Atransaction%3Abiitrns001%3Aver2.0%3Aextended%3Aurn%3Awww.peppol.eu%3Abis%3Apeppol3a%3Aver2.0%3A%3A2.1
   * </pre>
   */
  sRealCertificate = StringHelper.trimStart (sRealCertificate, BEGIN_CERTIFICATE_INVALID);
  sRealCertificate = StringHelper.trimEnd (sRealCertificate, END_CERTIFICATE_INVALID);

  // Remove regular PEM headers also
  sRealCertificate = StringHelper.trimStart (sRealCertificate, BEGIN_CERTIFICATE);
  sRealCertificate = StringHelper.trimEnd (sRealCertificate, END_CERTIFICATE);

  // Remove all existing whitespace characters
  return StringHelper.getWithoutAnySpaces (sRealCertificate);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:37,代码来源:CertificateHelper.java

示例4: _decompressAttachments

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
private static void _decompressAttachments (@Nonnull final Ebms3UserMessage aUserMessage,
                                            @Nonnull final IAS4MessageState aState,
                                            @Nonnull final ICommonsList <WSS4JAttachment> aIncomingDecryptedAttachments)
{
  for (final WSS4JAttachment aIncomingAttachment : aIncomingDecryptedAttachments.getClone ())
  {
    final EAS4CompressionMode eCompressionMode = aState.getAttachmentCompressionMode (aIncomingAttachment.getId ());
    if (eCompressionMode != null)
    {
      final IHasInputStream aOldISP = aIncomingAttachment.getInputStreamProvider ();
      aIncomingAttachment.setSourceStreamProvider (new HasInputStream ( () -> {
        try
        {
          return eCompressionMode.getDecompressStream (aOldISP.getInputStream ());
        }
        catch (final IOException ex)
        {
          throw new UncheckedIOException (ex);
        }
      }, aOldISP.isReadMultiple ()));

      final String sAttachmentContentID = StringHelper.trimStart (aIncomingAttachment.getId (), "attachment=");
      // x.getHref() != null needed since, if a message contains a payload and
      // an attachment, it would throw a NullPointerException since a payload
      // does not have anything written in its partinfo therefore also now
      // href
      final Ebms3PartInfo aPart = CollectionHelper.findFirst (aUserMessage.getPayloadInfo ().getPartInfo (),
                                                              x -> x.getHref () != null &&
                                                                   x.getHref ().contains (sAttachmentContentID));
      if (aPart != null)
      {
        final Ebms3Property aProperty = CollectionHelper.findFirst (aPart.getPartProperties ().getProperty (),
                                                                    x -> x.getName ()
                                                                          .equals (UserMessageCreator.PART_PROPERTY_MIME_TYPE));
        if (aProperty != null)
        {
          aIncomingAttachment.overwriteMimeType (aProperty.getValue ());
        }
      }
    }
  }
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:43,代码来源:AS4Handler.java

示例5: _convertToPackage

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Nonnull
private static String _convertToPackage (@Nonnull final String sNamespaceURI)
{
  // Lowercase everything
  String s = sNamespaceURI.toLowerCase (Locale.US);

  String [] aParts;
  final URL aURL = URLHelper.getAsURL (sNamespaceURI);
  if (aURL != null)
  {
    // Host
    String sHost = aURL.getHost ();

    // Kick static prefix: www.helger.com -> helger.com
    sHost = StringHelper.trimStart (sHost, "www.");

    // Reverse domain: helger.com -> com.helger
    final List <String> x = CollectionHelper.getReverseList (StringHelper.getExploded ('.', sHost));

    // Path in regular order:
    final String sPath = StringHelper.trimStart (aURL.getPath (), '/');
    x.addAll (StringHelper.getExploded ('/', sPath));

    // Convert to array
    aParts = ArrayHelper.newArray (x, String.class);
  }
  else
  {
    // Kick known prefixes
    for (final String sPrefix : new String [] { "urn:", "http://" })
      if (s.startsWith (sPrefix))
      {
        s = s.substring (sPrefix.length ());
        break;
      }

    // Replace all illegal characters
    s = StringHelper.replaceAll (s, ':', '.');
    s = StringHelper.replaceAll (s, '-', '_');
    aParts = StringHelper.getExplodedArray ('.', s);
  }

  // Split into pieces and replace all illegal package parts (e.g. only
  // numeric) with valid ones
  for (int i = 0; i < aParts.length; ++i)
    aParts[i] = RegExHelper.getAsIdentifier (aParts[i]);

  return StringHelper.getImploded (".", aParts);
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:50,代码来源:MainCreateJAXBBinding22.java

示例6: _convertToPackage

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Nonnull
private static String _convertToPackage (@Nonnull final String sNamespaceURI)
{
  // Lowercase everything
  String s = sNamespaceURI.toLowerCase (Locale.US);

  String [] aParts;
  final URL aURL = URLHelper.getAsURL (sNamespaceURI);
  if (aURL != null)
  {
    // Host
    String sHost = aURL.getHost ();

    // Kick static prefix: www.helger.com -> helger.com
    sHost = StringHelper.trimStart (sHost, "www.");

    // Reverse domain: helger.com -> com.helger
    final ICommonsList <String> x = StringHelper.getExploded ('.', sHost);
    x.reverse ();

    // Path in regular order:
    final String sPath = StringHelper.trimStart (aURL.getPath (), '/');
    x.addAll (StringHelper.getExploded ('/', sPath));

    // Convert to array
    aParts = ArrayHelper.newArray (x, String.class);
  }
  else
  {
    // Kick known prefixes
    for (final String sPrefix : new String [] { "urn:", "http://" })
      if (s.startsWith (sPrefix))
      {
        s = s.substring (sPrefix.length ());
        break;
      }

    // Replace all illegal characters
    s = StringHelper.replaceAll (s, ':', '.');
    s = StringHelper.replaceAll (s, '-', '_');
    aParts = StringHelper.getExplodedArray ('.', s);
  }

  // Split into pieces and replace all illegal package parts (e.g. only
  // numeric) with valid ones
  for (int i = 0; i < aParts.length; ++i)
    aParts[i] = RegExHelper.getAsIdentifier (aParts[i]);

  return StringHelper.getImploded (".", aParts);
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:51,代码来源:MainCreateJAXBBinding20.java


注:本文中的com.helger.commons.string.StringHelper.trimStart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。