List of usage examples for org.apache.commons.lang StringUtils leftPad
public static String leftPad(String str, int size, String padStr)
Left pad a String with a specified String.
From source file:org.opoo.press.util.LinkUtils.java
public static void addDateParams(Map<String, Object> params, Date date) { if (date == null) { date = new Date(); }/*from ww w . ja va 2 s.com*/ if (params == null) { return; } Calendar c = Calendar.getInstance(); c.setTime(date); int year = c.get(Calendar.YEAR); int monthnum = c.get(Calendar.MONTH) + 1; int day = c.get(Calendar.DAY_OF_MONTH); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int second = c.get(Calendar.SECOND); params.put("year", year + ""); params.put("month", StringUtils.leftPad(monthnum + "", 2, '0')); params.put("day", StringUtils.leftPad(day + "", 2, '0')); params.put("hour", StringUtils.leftPad(hour + "", 2, '0')); params.put("minute", StringUtils.leftPad(minute + "", 2, '0')); params.put("second", StringUtils.leftPad(second + "", 2, '0')); }
From source file:org.orcid.jaxb.model.common.Day.java
private String tidyValue(String value) { return StringUtils.leftPad(value, 2, '0'); }
From source file:org.orcid.jaxb.model.message.Day.java
public Day(Integer value) { this.value = StringUtils.leftPad(Integer.toString(value), 2, '0'); }
From source file:org.orcid.jaxb.model.message.Month.java
public Month(Integer value) { this.value = StringUtils.leftPad(Integer.toString(value), 2, '0'); }
From source file:org.orcid.utils.DateUtils.java
private static String tidy(String dateString) { if (dateString == null) { return null; }/* ww w . j ava 2 s . c o m*/ Matcher matcher = DATE_PATTERN.matcher(dateString); if (!matcher.matches()) { return null; } String year = matcher.group(1); String month = matcher.group(2); String day = matcher.group(3); String time = matcher.group(4); StringBuilder builder = new StringBuilder(); builder.append(StringUtils.leftPad(year, 4, '0')); if (month != null) { builder.append('-'); month = mapSeasonsAndQuartersToMonth(month); builder.append(StringUtils.leftPad(month, 2, '0')); } if (day != null) { builder.append('-'); builder.append(StringUtils.leftPad(day, 2, '0')); } if (time != null) { builder.append(time); } return builder.toString(); }
From source file:org.owasp.jbrofuzz.core.Fuzzer.java
/** * <p>Return the next element of the fuzzer during iteration.</p> * /*from w w w. j a va 2 s . co m*/ * <p>This method should be used to access fuzzing payloads, after * construction of the fuzzer object.</p> * * @return String The next fuzzer payload, during the iteration * process * * @author subere@uncon.org * @version 2.0 * @since 1.2 */ public String next() { final StringBuffer output = new StringBuffer(); // Replacive Prototype if (maxValue == payloads.size()) { cValue++; output.append(payloads.get((int) cValue - 1)); } // Recursive Prototype else { long val = cValue; // Perform division on a stack final Stack<Integer> stack = new Stack<Integer>(); while (val >= payloads.size()) { stack.push(Integer.valueOf((int) val % payloads.size())); val = val / payloads.size(); } // Append the relevant empty positions with the first element // identified output.append(StringUtils.leftPad(payloads.get((int) val), len - stack.size(), payloads.get(0))); while (!stack.isEmpty()) { output.append(payloads.get(stack.pop().intValue())); } cValue++; } return output.toString(); }
From source file:org.owasp.jbrofuzz.core.FuzzerBigInteger.java
/** * <p>Return the next element of the fuzzer during iteration.</p> * //from ww w. ja va2 s .c o m * <p>This method should be used to access fuzzing payloads, after * construction of the fuzzer object.</p> * * @return String The next fuzzer payload, during the iteration * process * * @author subere@uncon.org * @version 2.4 * @since 1.2 */ public String next() { final StringBuffer output = new StringBuffer(""); // Replacive Prototype if (maxValue.compareTo(BigInteger.valueOf(payloads.size())) == 0) { output.append(payloads.get(cValue.intValue())); cValue = cValue.add(BigInteger.ONE); } // Recursive Prototype else { BigInteger val = cValue; // Perform division on a stack final Stack<BigInteger> stack = new Stack<BigInteger>(); while (val.compareTo(BigInteger.valueOf(payloads.size())) >= 0) { stack.push(val.mod(BigInteger.valueOf(payloads.size()))); val = val.divide(BigInteger.valueOf(payloads.size())); } // Append the relevant empty positions with the first element // identified output.append(StringUtils.leftPad(payloads.get(val.intValue()), len - stack.size(), payloads.get(0))); while (!stack.isEmpty()) { output.append(payloads.get(stack.pop().intValue())); } cValue = cValue.add(BigInteger.ONE); } return output.toString(); }
From source file:org.owasp.jbrofuzz.core.net.MACAddrFuzzer.java
/** * <p>Return the next MAC Address element.</p> * /* w w w .ja v a 2 s . com*/ * @return String 00<->11<->22<->33<->44<->55 where * <-> could be any of the type specified by the * Separator enum. * * @author subere@uncon.org * @version 2.5 * @since 2.5 * */ public String next() { final StringBuffer output = new StringBuffer(17); long val = currentValue; // Perform division on a stack final Stack<Integer> stack = new Stack<Integer>(); while (val >= 16) { stack.push(Integer.valueOf((int) val % 16)); val = val / 16; } // Append the relevant empty positions with the first element // identified output.append(StringUtils.leftPad(Character.toString(hexCharArray[(int) val]), 12 - stack.size(), "0")); while (!stack.isEmpty()) { output.append(Character.toString(hexCharArray[stack.pop().intValue()])); } currentValue++; if (separator == Separator.NONE) { return output.toString(); } else { char delim; //Add the character delimeter switch (separator) { case HYPHEN: delim = '-'; break; case COLON: delim = ':'; break; case SPACE: delim = ' '; break; case UNDERSCORE: delim = '_'; break; default: delim = ':'; break; } for (int index = 2; index < 17; index += 3) { output.insert(index, delim); } } return output.toString(); }
From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java
/** * <p>// w w w . ja va2 s .c om * Method for returning the counter held within the Sniffing Panel which is * responsible for counting the number of requests having been made. This * method is used for generating unique sequential file name and row counts. * </p> * * @param newCount * boolean Increment the counter by 1 * @return String */ public String getCounter() { // Loop the counter after 1 billion requests if ((counter < 0) || (counter > 1000000000)) { counter = 1; } counter++; return StringUtils.leftPad(Integer.toString(counter), 10, '0'); }
From source file:org.owasp.jbrofuzz.fuzz.ui.OutputTableModel.java
public void addNewRow(MessageContainer outputMessage) { this.addRow(new Object[] { outputMessage.getFileName(), outputMessage.getTextURL(), StringUtils.abbreviate(outputMessage.getPayload(), 50), StringUtils.abbreviate(outputMessage.getEncodedPayload(), 50), outputMessage.getStatus(), StringUtils.leftPad("" + outputMessage.getResponseTime(), 5, '0'), StringUtils.leftPad("" + outputMessage.getByteCount(), 8, '0') });/* w w w . j a v a2s . c o m*/ }