xlawrence 2005/11/04 10:30:37 CET
Modified files:
core/src/java/org/jahia/taglibs/util Utils.java
Log:
code optimizations and cleanup
Revision Changes Path
1.4 +14 -12 jahia/core/src/java/org/jahia/taglibs/util/Utils.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/util/Utils.java.diff?r1=1.3&r2=1.4&f=h
Index: Utils.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/util/Utils.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Utils.java 4 Nov 2005 09:05:24 -0000 1.3
+++ Utils.java 4 Nov 2005 09:30:36 -0000 1.4
@@ -32,9 +32,10 @@
*
* @return the new name for the current tag, used by Jahia to retrieve
him
*/
- public static String buildUniqueName (String parentName, String tagName)
{
+ public static String buildUniqueName (final String parentName, final
String tagName) {
- StringBuffer buffer = new StringBuffer(parentName);
+ final StringBuffer buffer = new StringBuffer();
+ buffer.append(parentName);
buffer.append(SEPARATOR);
buffer.append(tagName);
return buffer.toString();
@@ -50,7 +51,7 @@
*
* @return the name for the parent tag
*/
- public static String getParentName (String completeName, String tagName)
{
+ public static String getParentName (final String completeName, final
String tagName) {
if (completeName.endsWith(SEPARATOR + tagName)) {
// checks if the completeName ends with the tagName
@@ -74,8 +75,8 @@
* @param replaceValue the value to insert where token is found
* @return the new String
*/
- public static String replace(String str, String token,
- String replaceValue) {
+ public static String replace(String str, final String token,
+ final String replaceValue) {
String result = "";
int i = str.indexOf(token);
@@ -100,13 +101,14 @@
*
* @return the new link
*/
- public static String insertContextPath(String contextPath, String link) {
+ public static String insertContextPath(final String contextPath, final
String link) {
int pos = link.indexOf("src=");
if (pos != -1) {
- StringBuffer tmp = new StringBuffer(link);
+ final StringBuffer tmp = new StringBuffer();
+ tmp.append(link);
// insert after "src='"
- tmp = tmp.insert(pos + 5, contextPath + "/");
+ tmp.insert(pos + 5, contextPath + "/");
return tmp.toString();
}
// no image in link : remains the same
@@ -124,10 +126,10 @@
*
* @return the short name
*/
- public static String getShortClassName(Class theClass) {
+ public static String getShortClassName(final Class theClass) {
- String fullName = theClass.getName();
- int lastDot = fullName.lastIndexOf(".");
+ final String fullName = theClass.getName();
+ final int lastDot = fullName.lastIndexOf(".");
if (lastDot == -1) {
JahiaConsole.println("Utils: getShortClassName ", "The class
name contains no dot.");
return fullName;
@@ -141,7 +143,7 @@
* @param enum the enumeration
* @return its size
*/
- public static int enumSize(Enumeration enum) {
+ public static int enumSize(final Enumeration enum) {
int i = 0;
while(enum.hasMoreElements()) {
i++;