Questions tagged [apache-commons-lang]

The standard Java libraries fail to provide enough methods for manipulation of its core classes. Apache Commons Lang provides these extra methods.

Apache Commons Lang provides a host of helper utilities for the java.lang API, notably string manipulation methods, basic numerical methods, object reflection, concurrency, creation and serialization and System properties. Additionally it contains basic enhancements to java.util.Date and a series of utilities dedicated to help with building methods, such as hashCode(), toString() and equals().

Note that Lang 3.0 (and subsequent versions) use a different package (org.apache.commons.lang3) than the previous versions (org.apache.commons.lang), allowing it to be used at the same time as an earlier version.

Official Website: http://commons.apache.org/lang/

Useful Links:

Related Tags:

80 questions
2
votes
2 answers

Apache Commons Lang HashCodeBuilder collision

I am getting collision with using Apache Commons Lang HashCodeBuilder using release 3.4. I am hashing a Route object, which contains two Cell objects, start and end. At the end I am providing an example when collision occurs. Both classes override…
Jernej Jerin
  • 3,179
  • 9
  • 37
  • 53
2
votes
1 answer

Stringutils.join Alternative Way

Are there any alternative way of using the following? I am using Apache commons.lang jar for StringUtils.join however I do have a problem with class loading to Weblogic server and hence it wouldn't be good to use StringUtils.join. So instead I am…
Jacob
  • 14,463
  • 65
  • 207
  • 320
2
votes
3 answers

How can I include the caret character ^ in an Apache Commons CharSet?

The Apache Commons CharSet class has its own syntax for characters to be included in the set. In that syntax the caret character (^) has special meaning (negation) but there isn't any documentation about how to include the caret in the set itself…
E-Riz
  • 31,431
  • 9
  • 97
  • 134
2
votes
2 answers

String.trimLeft and trimRight in dart

How to define trimLeft and trimRight functions for String? I can't find a simple solution to implement them. My tricky solution is: String _trimLeft(String str) { var s = (str + '.').trim(); return s.substring(0, s.length-1); } String…
Freewind
  • 193,756
  • 157
  • 432
  • 708
1
vote
0 answers

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils

Given below is the error. I have added the apache.org.common.lang jar still am getting this . am having these .JARs in my lib folder am is missing on…
Salva
  • 81
  • 1
  • 9
1
vote
1 answer

The result of xor(true, true, true) of the BooleanUtils class under the commons-lang toolkit under Apache is false, why?

The result of xor(true, true, true) of the BooleanUtils class under the commons-lang toolkit under Apache is false, but the result of System.out.println(true ^ true ^ true) is true. Why? public class Test { public static void main(String[] args)…
mochen
  • 15
  • 3
1
vote
2 answers

Apache lang3 works but Apache lang does not. Why?

I have implemented the spring boot project with starter parent pom version 2.0.3. When I try to use import org.apache.commons.lang.StringUtils it throws error import cannot be resolved. Even though my m2 folder…
1
vote
2 answers

Output all of the values for variables in an object using reflection

I would like to output all of the values for variables in an object. Currently I am using ReflectionToStringBuilder but the problem is that it includes the [,] characters when outputting collections. Here is an example. import…
Michael
  • 3,411
  • 4
  • 25
  • 56
1
vote
0 answers

How to make templateString dynamic in StrSubstitutor

String[] greetings = {"Hello1", "Hello2", "Hello3"}; String otherString = "green"; Map valuesMap = new HashMap(); valuesMap.put("greeting", greetings); valuesMap.put("color", otherString ); String…
1
vote
1 answer

Java 9 JRE causes java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils on jar execution

I created a jar file on Eclipse Oxygen.1a (OS:Windows 10 Home edition 64-bit). My project's JRE is jre1.8.0_152(64-bit version). When I run my jar file using the Java 8 JRE, program works perfectly but when I use the Java 9 JRE I get the following…
1
vote
2 answers

In what format does ToStringBuilder.reflectionToString(Object) display dates?

In what format does ToStringBuilder.reflectionToString(Object) display dates? According to the Apache Commons Lang 2.4 documentation, ToStringBuilder.reflectionToString(Object) delegates to ReflectionToStringBuilder.toString(Object) which "Builds a…
Derek Mahar
  • 27,608
  • 43
  • 124
  • 174
1
vote
3 answers

How to install commons-lang src to local repository?

I want to use the commons-lang by maven,but apache repository isn't ,I down commons-lang-src publish in local repository ,but is warning. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test (default-test) on…
EdwardLau
  • 1,139
  • 4
  • 20
  • 26
1
vote
1 answer

Despite having commons-lang included in pom, getting exception java.lang.NoSuchMethodError:org.apache.commons.lang.StringUtils.join

I have the following String pattern = "\\b(" + StringUtils.join(mypattern, "|") + ")\\b"; and in pom.xml, I have dependency for commons-lang commons-lang
Jacob
  • 14,463
  • 65
  • 207
  • 320
1
vote
1 answer

Change output for a particular occurence of a type with ReflectionToStringBuilder

I'm using the Apache Common Lang ReflectionToStringBuilder to recursively give me a toString for my entities. I have a custom ToStringStyle that I'm using to give me a slightly modified output, and I'm omitting some variables that I don't want to…
Newmanater
  • 153
  • 1
  • 12
1
vote
1 answer

Can't convert double array to String using Apache Commons Lang

I have been trying to convert a double array to a string where numbers are separated with a space. public class StringTest { public static void main(String[] args) { double[] g = {1.2,1.4,1.4} ; String d = StringUtils.join(g,…
zamk
  • 71
  • 3
  • 14