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


Java StringHelper.getRepeated方法代码示例

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


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

示例1: main

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
public static void main (final String [] args) throws IOException
{
  s_aLogger.info ("Reading");
  final InvoiceType aInvoice = UBL21Reader.invoice ()
                                          .read (new FileSystemResource ("src/test/resources/xml/as2-test-at-gov.xml"));

  final String sNote = StringHelper.getRepeated ('X', 1024);
  final long nNotes = 2 * CGlobal.BYTES_PER_GIGABYTE / sNote.length ();
  s_aLogger.info ("Adding " + nNotes + " notes");
  for (long i = 0; i < nNotes; ++i)
    aInvoice.addNote (new NoteType (sNote));
  s_aLogger.info ("Writing");
  UBL21Writer.invoice ()
             .write (aInvoice,
                     new GZIPOutputStream (new FileSystemResource ("src/test/resources/xml/as2-test-at-gov-2gb.gz").getOutputStream (EAppend.TRUNCATE)));
  s_aLogger.info ("Done");
}
 
开发者ID:phax,项目名称:as2-peppol-client,代码行数:18,代码来源:MainCreate2GBXMLFile.java

示例2: testCellSpawningPage

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Test
public void testCellSpawningPage () throws PDFCreationException
{
  final FontSpec r10 = new FontSpec (PreloadFont.REGULAR, 10);

  final PLPageSet aPS1 = new PLPageSet (PDRectangle.A4);

  aPS1.addElement (new PLText ("First line", r10).setID ("first-line"));

  // Start table
  final String sLongText = StringHelper.getRepeated ("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n",
                                                     10);
  final PLTable aTable = PLTable.createWithEvenlySizedColumns (3).setID ("table");
  aTable.addAndReturnRow (new PLTableCell (new PLText (sLongText, r10).setID ("longtext")).setID ("celllongtext"),
                          new PLTableCell (new PLSpacerX (0).setID ("empty")).setID ("cellempty"),
                          new PLTableCell (new PLText ("Short text",
                                                       r10).setID ("shorttext")).setID ("cellshorttext"))
        .setID ("row");
  EPLTableGridType.FULL.applyGridToTable (aTable, new BorderStyleSpec (Color.RED));
  aPS1.addElement (aTable);

  aPS1.addElement (new PLText ("Last line", r10).setID ("last-line"));

  final PageLayoutPDF aPageLayout = new PageLayoutPDF ().setCompressPDF (false);
  aPageLayout.addPageSet (aPS1);
  aPageLayout.renderTo (FileHelper.getOutputStream (new File ("pdf/test-pltable-cell-spawning-page.pdf")));
}
 
开发者ID:phax,项目名称:ph-pdf-layout,代码行数:28,代码来源:PLTableTest.java

示例3: getFormatted

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
/**
 * Source: http://www.luschny.de/java/doubleformat.html
 *
 * @param dValue
 *        the value to be formatted
 * @param nScale
 *        The precision of the decimal scale. If type is
 *        {@link EDecimalType#FIX} the decimal scale, else the (carrying scale
 *        - 1). Should be &ge; 0.
 * @param eType
 *        The formatting type. May not be <code>null</code>.
 * @param aLocale
 *        The locale to be used for the decimal symbols. May not be
 *        <code>null</code>.
 * @return the string representation of the double value. For NaN and infinite
 *         values, the return of {@link Double#toString()} is returned.
 */
@Nonnull
public static String getFormatted (final double dValue,
                                   @Nonnegative final int nScale,
                                   @Nonnull final EDecimalType eType,
                                   @Nonnull final Locale aLocale)
{
  ValueEnforcer.isGE0 (nScale, "Scale");
  ValueEnforcer.notNull (eType, "Type");
  ValueEnforcer.notNull (aLocale, "Locale");

  if (Double.isNaN (dValue) || Double.isInfinite (dValue))
    return Double.toString (dValue);

  // Avoid negative scales
  final DecimalFormat aDF = (DecimalFormat) NumberFormat.getInstance (aLocale);
  aDF.setDecimalFormatSymbols (DecimalFormatSymbols.getInstance (aLocale));
  aDF.setMaximumFractionDigits (nScale);
  aDF.setMinimumFractionDigits (nScale);

  if (eType.isExponential ())
  {
    String sPattern = "0E0";
    if (nScale > 0)
      sPattern += '.' + StringHelper.getRepeated ('0', nScale);
    aDF.applyPattern (sPattern);
  }
  else
  {
    aDF.setGroupingUsed (false);
    aDF.setMinimumIntegerDigits (1);
  }
  return aDF.format (dValue);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:51,代码来源:RoundHelper.java

示例4: apply

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Override
public String apply (@Nullable final Object aValue)
{
  final String s = getValueAsString (aValue);
  if (s.length () >= m_nMinLength)
    return s;
  return StringHelper.getRepeated (m_cFill, m_nMinLength - s.length ()) + s;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:9,代码来源:FormatterMinLengthAddLeading.java

示例5: apply

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Override
public String apply (@Nullable final Object aValue)
{
  final String s = getValueAsString (aValue);
  if (s.length () >= m_nMinLength)
    return s;
  return s + StringHelper.getRepeated (m_cFill, m_nMinLength - s.length ());
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:9,代码来源:FormatterMinLengthAddTrailing.java

示例6: testAll

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Test
public void testAll () throws IOException
{
  final NonBlockingStringReader baos = new NonBlockingStringReader (StringHelper.getRepeated ('a', 100));
  try (final WrappedReader ws = new WrappedReader (baos))
  {
    assertTrue (ws.markSupported ());
    assertTrue (ws.ready ());
    ws.mark (0);
    ws.read ();
    assertEquals (4, ws.read (new char [4]));
    assertEquals (1, ws.read (new char [5], 1, 1));
    ws.read (CharBuffer.allocate (1));
    assertEquals (4, ws.skip (4));
    assertEquals (89, ws.skip (100));
    ws.reset ();
    assertEquals (100, ws.skip (100));
    CommonsTestHelper.testToStringImplementation (ws);
  }

  try (WrappedReader aReader = new WrappedReader (null))
  {
    fail ();
  }
  catch (final NullPointerException ex)
  {}
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:28,代码来源:WrappedReaderTest.java

示例7: testColSpanRightAlign

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Test
public void testColSpanRightAlign () throws PDFCreationException
{
  final FontSpec r10 = new FontSpec (PreloadFont.REGULAR, 10);
  final PLPageSet aPS1 = new PLPageSet (PDRectangle.A4);

  aPS1.addElement (new PLText ("First line", r10).setID ("first-line"));

  final String sLongText = StringHelper.getRepeated ("This is a dummy text to fill the table cell. Some other real information expected here in practice. ",
                                                     6);

  final String sMediumText = StringHelper.getRepeated ("This is a dummy text to fill the table cell. Some other real information expected here in practice. ",
                                                       2);

  // Start table
  final PLTable aTable = PLTable.createWithPercentage (10, 60, 15, 15).setHeaderRowCount (1).setID ("table");
  aTable.addAndReturnRow (new PLTableCell (new PLText ("Header col 1", r10)),
                          new PLTableCell (new PLText ("Header col 2", r10)),
                          new PLTableCell (new PLText ("Header col 3", r10)),
                          new PLTableCell (new PLText ("Header col 4", r10)))
        .setID ("row-header")
        .setPadding (2)
        .setFillColor (Color.LIGHT_GRAY);
  for (int i = 0; i < 12; ++i)
  {
    aTable.addAndReturnRow (new PLTableCell (new PLText (Integer.toString (i), r10).setID ("idx")).setID ("cell-idx"),
                            new PLTableCell (new PLText (sLongText, r10).setID ("longtext")).setID ("cell-longtext"),
                            new PLTableCell (new PLSpacerX (0).setID ("empty")).setID ("cell-empty"),
                            new PLTableCell (new PLText ("Short text",
                                                         r10).setID ("shorttext")).setID ("cell-shorttext"))
          .setID ("row-content-" + i)
          .setPadding (2);
    aTable.addAndReturnRow (new PLTableCell (new PLText (sMediumText, r10).setID ("spanned")
                                                                          .setHorzAlign (EHorzAlignment.RIGHT),
                                             aTable.getColumnCount ()).setID ("cell-spanned")
                                                                      .setHorzAlign (EHorzAlignment.RIGHT))
          .setID ("row-summary-" + i)
          .setPadding (2);
  }
  EPLTableGridType.FULL.applyGridToTable (aTable, new BorderStyleSpec (Color.PINK));
  aPS1.addElement (aTable);

  aPS1.addElement (new PLText ("Last line", r10).setID ("last-line"));

  PLDebugRender.withDebugRender (false, () -> {
    final PageLayoutPDF aPageLayout = new PageLayoutPDF ().setCompressPDF (false);
    aPageLayout.addPageSet (aPS1);
    aPageLayout.renderTo (FileHelper.getOutputStream (new File ("pdf/test-pltable-colspan-right-align.pdf")));
  });
}
 
开发者ID:phax,项目名称:ph-pdf-layout,代码行数:51,代码来源:PLTableTest.java

示例8: getIndent

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Nonnull
public final String getIndent (@Nonnegative final int nCount)
{
  return StringHelper.getRepeated (m_sIndent, nCount);
}
 
开发者ID:phax,项目名称:ph-css,代码行数:6,代码来源:CSSWriterSettings.java

示例9: testAutoHeightAdvancedSplittable

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
@Test
public void testAutoHeightAdvancedSplittable () throws PDFCreationException
{
  final String s1 = "This is a test";
  final String s2 = "This is also a test string \nbut much much much much longer as the other one. \nCan you believe this???? \nNo this is not believable\nThis\nshall\ncreate\nmore\nlines\n\n!";
  final String s3 = StringHelper.getRepeated (s2, 6);

  final FontSpec r10 = new FontSpec (PreloadFont.REGULAR, 10);
  final PLPageSet aPS1 = new PLPageSet (PDRectangle.A4).setID ("p");

  int nCount = 0;
  for (int h = 0; h < 2; h++)
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j)
        for (int k = 0; k < 2; ++k)
        {
          if (nCount++ > 0)
          {
            aPS1.addElement (new PLText ("Forced page break following", r10));
            aPS1.addElement (new PLPageBreak (false));
          }

          final String sIDPrefix = h + "-" + i + "-" + j + "-" + k + "-";
          final PLVBox aVBox = new PLVBox ().setID (sIDPrefix + "vbox")
                                            .setFullWidth (h == 0)
                                            .setVertSplittable (true);
          aVBox.addRow (new PLText ("This is a " +
                                    (h == 0 ? "full-width" : "regular width") +
                                    " example (" +
                                    sIDPrefix +
                                    ").",
                                    r10).setBorder (Color.RED));
          aVBox.addRow (new PLBox (new PLText ("Ich bin ein Stern", r10).setID (sIDPrefix + "t1"))
                                                                                                  .setID (sIDPrefix +
                                                                                                          "star1")
                                                                                                  .setBorder (Color.BLUE),
                        HeightSpec.star ());
          aVBox.addRow (new PLBox (new PLText (i == 0 ? s1 : s3, r10).setID (sIDPrefix + "t2")
                                                                     .setVertSplittable (true)).setID (sIDPrefix +
                                                                                                       "auto1")
                                                                                               .setBorder (Color.RED)
                                                                                               .setVertSplittable (true),
                        HeightSpec.auto ());
          aVBox.addRow (new PLBox (new PLText (j == 0 ? s1 : s3, r10).setID (sIDPrefix + "t3")
                                                                     .setVertSplittable (true)).setID (sIDPrefix +
                                                                                                       "auto2")
                                                                                               .setBorder (Color.YELLOW)
                                                                                               .setVertSplittable (true),
                        HeightSpec.auto ());
          aVBox.addRow (new PLBox (new PLText (k == 0 ? s1 : s3, r10).setID (sIDPrefix + "t4")
                                                                     .setVertSplittable (true)).setID (sIDPrefix +
                                                                                                       "auto3")
                                                                                               .setBorder (Color.GREEN)
                                                                                               .setVertSplittable (true),
                        HeightSpec.auto ());
          aVBox.addRow (new PLBox (new PLText ("Ich bin ein Stern", r10).setID (sIDPrefix + "t5"))
                                                                                                  .setID (sIDPrefix +
                                                                                                          "star2")
                                                                                                  .setBorder (Color.BLUE),
                        HeightSpec.star ());
          aPS1.addElement (aVBox);
        }

  final PageLayoutPDF aPageLayout = new PageLayoutPDF ();
  aPageLayout.addPageSet (aPS1);
  aPageLayout.renderTo (FileHelper.getOutputStream (new File ("pdf/test-plvbox-auto-advanced-splittable.pdf")));
}
 
开发者ID:phax,项目名称:ph-pdf-layout,代码行数:68,代码来源:PLVBoxTest.java

示例10: createPadding

import com.helger.commons.string.StringHelper; //导入方法依赖的package包/类
/**
 * Return a String of padding of length <code>len</code>.
 *
 * @param nLen
 *        The length of the String of padding to create.
 * @return The String of padding
 */
@Nonnull
protected static String createPadding (@Nonnegative final int nLen)
{
  return StringHelper.getRepeated (' ', nLen);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:13,代码来源:HelpFormatter.java


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