List of usage examples for org.apache.commons.lang StringUtils repeat
public static String repeat(String str, int repeat)
Repeat a String repeat
times to form a new String.
From source file:com.adobe.acs.commons.util.InfoWriterTest.java
@Test public void testEnd() throws Exception { String expected = StringUtils.repeat("-", 80); iw.end();/*from ww w .j a va 2s .co m*/ assertEquals(expected.concat(LS), iw.toString()); }
From source file:me.bogeymanEST.cmdhelper.output.Output.java
private String newLine() { if (pretty)/*from w w w . j a v a2s . c om*/ return "\n" + StringUtils.repeat("\t", stackLevel); return ""; }
From source file:biz.netcentric.cq.tools.actool.helper.AcHelper.java
public static String getBlankString(final int nrOfBlanks) { return StringUtils.repeat(" ", nrOfBlanks); }
From source file:com.amazonaws.services.kinesis.producer.KinesisProducerTest.java
@Test public void differentCredsForRecordsAndMetrics() throws InterruptedException, ExecutionException { final String AKID_A = "AKIAAAAAAAAAAAAAAAAA"; final String AKID_B = "AKIABBBBBBBBBBBBBBBB"; final KinesisProducer kp = getProducer( new StaticCredentialsProvider(new BasicAWSCredentials(AKID_A, StringUtils.repeat("a", 40))), new StaticCredentialsProvider(new BasicAWSCredentials(AKID_B, StringUtils.repeat("b", 40)))); final long start = System.nanoTime(); while (System.nanoTime() - start < 500 * 1000000) { kp.addUserRecord("a", "a", ByteBuffer.wrap(new byte[0])); kp.flush();/*from w w w .ja va 2s .c o m*/ Thread.sleep(10); } kp.flushSync(); kp.destroy(); Map<String, AtomicInteger> counts = new HashMap<String, AtomicInteger>(); counts.put(AKID_A, new AtomicInteger(0)); counts.put(AKID_B, new AtomicInteger(0)); for (ClientRequest cr : server.getRequests()) { String auth = cr.getHeaders().get("Authorization"); if (auth == null) { auth = cr.getHeaders().get("authorization"); } String host = cr.getHeaders().get("Host"); if (host == null) { cr.getHeaders().get("host"); } if (auth.contains(AKID_B)) { assertFalse(host.contains("kinesis")); counts.get(AKID_B).getAndIncrement(); } else if (auth.contains(AKID_A)) { assertFalse(host.contains("monitoring")); counts.get(AKID_A).getAndIncrement(); } else { fail("Expected AKID(s) not found in auth header"); } } assertTrue(counts.get(AKID_A).get() > 1); assertTrue(counts.get(AKID_B).get() > 1); }
From source file:adalid.core.expressions.AbstractRowsAggregateX.java
@Override protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) { String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; String faa = " = "; String foo = verbose ? EOL : ", "; String string = super.fieldsToString(n, key, verbose, fields, maps); if (fields || verbose) { if (verbose) { string += fee + tab + "operator" + faa + _operator + foo; string += fee + tab + "operand" + faa + getValueString(_measure) + foo; if (_filter != null) { string += fee + tab + "segment" + faa + getValueString(_filter) + foo; }/*from w w w . j ava 2 s. c o m*/ if (_dimension != null) { string += fee + tab + "property" + faa + getValueString(_dimension) + foo; } } } return string; }
From source file:com.adobe.acs.commons.util.InfoWriterTest.java
@Test public void testLine() throws Exception { String expected = StringUtils.repeat("-", 80); iw.line();//from w ww . ja v a2 s .c o m assertEquals(expected.concat(LS), iw.toString()); }
From source file:adalid.core.expressions.AbstractConditionalX.java
@Override protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) { String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; String faa = " = "; String foo = verbose ? EOL : ", "; String string = super.fieldsToString(n, key, verbose, fields, maps); Expression e;/*from w w w .ja v a2 s. c o m*/ if (fields || verbose) { if (verbose) { if (_booleanExpression != null) { string += _booleanExpression.toString(n + 1, "booleanExpression"); } if (_thenValue != null) { if (_thenValue instanceof NaryExpression) { e = (Expression) _thenValue; string += e.toString(n + 1, "thenExpression"); } else { string += fee + tab + "thenExpression" + faa + getValueString(_thenValue) + foo; } } if (_elseValue != null) { if (_elseValue instanceof NaryExpression) { e = (Expression) _elseValue; string += e.toString(n + 1, "elseExpression"); } else { string += fee + tab + "elseExpression" + faa + getValueString(_elseValue) + foo; } } } } return string; }
From source file:de.keyle.mypet.npc.MyPetNpcPlugin.java
public void onEnable() { plugin = this; MyPetNpcVersion.reset();//from ww w. j ava2 s . c om if (!Bukkit.getPluginManager().isPluginEnabled("MyPet")) { getLogger().info("MyPet is not installed/enabled. Activating dummy traits!"); CitizensAPI.getTraitFactory() .registerTrait(TraitInfo.create(DummyStorageTrait.class).withName("mypet-storage")); CitizensAPI.getTraitFactory() .registerTrait(TraitInfo.create(DummyWalletTrait.class).withName("mypet-wallet")); CitizensAPI.getTraitFactory() .registerTrait(TraitInfo.create(DummyShopTrait.class).withName("mypet-shop")); return; } replaceLogger(); if (MyPetApi.getPlugin().getConfig().getBoolean("MyPet.Update-Check", true)) { Optional<String> message = UpdateCheck.checkForUpdate(); if (message.isPresent()) { String m = "# A new version is available: " + message.get() + " #"; MyPetApi.getLogger().info(StringUtils.repeat("#", m.length())); MyPetApi.getLogger().info(m); MyPetApi.getLogger().info(StringUtils.repeat("#", m.length())); } } if (Integer.parseInt(MyPetVersion.getBuild()) < Integer.parseInt(MyPetNpcVersion.getRequiredMyPetBuild())) { boolean premium = false; try { premium = MyPetVersion.isPremium(); } catch (NoSuchMethodError ignored) { } if (premium) { if (Integer.parseInt(MyPetVersion.getBuild()) < Integer .parseInt(MyPetNpcVersion.getRequiredMyPetPremiumBuild())) { getLogger().warning(ChatColor.RED + "This version of MyPet-NPC requires MyPet-Premium build-#" + MyPetNpcVersion.getRequiredMyPetPremiumBuild() + " or higher"); this.setEnabled(false); return; } } else { getLogger().warning(ChatColor.RED + "This version of MyPet-NPC requires MyPet build-#" + MyPetNpcVersion.getRequiredMyPetBuild() + " or higher"); this.setEnabled(false); return; } } new Metrics(this); File configFile = new File(MyPetApi.getPlugin().getDataFolder().getPath() + File.separator + "plugins" + File.separator + "NPC" + File.separator + "config.yml"); configFile.getParentFile().mkdirs(); Configuration.yamlConfig = new ConfigurationYAML(configFile); Configuration.setDefault(); Configuration.loadConfiguration(); CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(StorageTrait.class).withName("mypet-storage")); CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(WalletTrait.class).withName("mypet-wallet")); if (MyPetVersion.isPremium()) { CitizensAPI.getTraitFactory().registerTrait(TraitInfo.create(ShopTrait.class).withName("mypet-shop")); } else { CitizensAPI.getTraitFactory() .registerTrait(TraitInfo.create(DummyShopTrait.class).withName("mypet-shop")); } getCommand("mypetnpcconfig").setExecutor(new CommandConfig()); getLogger().info("version " + MyPetNpcVersion.getVersion() + "-b" + MyPetNpcVersion.getBuild() + ChatColor.GREEN + " ENABLED"); }
From source file:com.rest4j.impl.UtilTest.java
@Test public void testClone() { Tree test = new Tree(); test.name = StringUtils.repeat("TEST", 10000); test.left = new Tree(); test.right = test.left;// w w w . j a va 2s . c om ThreadMXBean threadMx = ManagementFactory.getThreadMXBean(); long start = threadMx.getCurrentThreadCpuTime(); int N = 10000; for (int i = 0; i < N; i++) test = Util.deepClone(test); System.out.println("cloned in " + (threadMx.getCurrentThreadCpuTime() - start) / N + "ns"); assertSame(test.left, test.right); }
From source file:adalid.core.InstanceField.java
@Override protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) { String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; String faa = " = "; String foo = verbose ? EOL : ", "; String property = _property.getName(); String value = _value + ""; String string = super.fieldsToString(n, key, verbose, fields, maps); if (fields || verbose) { if (verbose) { string += fee + tab + "property" + faa + property + foo; string += fee + tab + "value" + faa + value + foo; }//www .ja v a2s. co m } return string; }