Author: mbrohl
Date: Sun Dec 17 16:57:56 2017 New Revision: 1818495 URL: http://svn.apache.org/viewvc?rev=1818495&view=rev Log: Improved: General refactoring and code improvements, package org.apache.ofbiz.base.util. (OFBIZ-9944) Thanks Dennis Balkir for reporting and providing the patches. Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectInputStream.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observable.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observer.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ReferenceCleaner.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelper.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Scriptlet.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/URLConnector.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilDateTime.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilFormatOut.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilIO.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilJavaParse.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilPlist.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilTimer.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilURL.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilValidate.java ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilXml.java Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java Sun Dec 17 16:57:56 2017 @@ -49,7 +49,9 @@ public class AliasKeyManager implements if (aliases != null && aliases.length > 0) { for (String alias: aliases) { if (this.alias.equals(alias)) { - if (Debug.verboseOn()) Debug.logVerbose("chooseClientAlias for keyType [" + keyType + "] got alias " + this.alias, module); + if (Debug.verboseOn()) { + Debug.logVerbose("chooseClientAlias for keyType [" + keyType + "] got alias " + this.alias, module); + } return this.alias; } } @@ -70,7 +72,9 @@ public class AliasKeyManager implements public X509Certificate[] getCertificateChain(String alias) { X509Certificate[] certArray = keyManager.getCertificateChain(alias); - if (Debug.verboseOn()) Debug.logVerbose("getCertificateChain for alias [" + alias + "] got " + certArray.length + " results", module); + if (Debug.verboseOn()) { + Debug.logVerbose("getCertificateChain for alias [" + alias + "] got " + certArray.length + " results", module); + } return certArray; } @@ -80,7 +84,9 @@ public class AliasKeyManager implements public PrivateKey getPrivateKey(String alias) { PrivateKey pk = keyManager.getPrivateKey(alias); - if (Debug.verboseOn()) Debug.logVerbose("getPrivateKey for alias [" + alias + "] got " + (pk == null ? "[Not Found!]" : "[alg:" + pk.getAlgorithm() + ";format:" + pk.getFormat() + "]"), module); + if (Debug.verboseOn()) { + Debug.logVerbose("getPrivateKey for alias [" + alias + "] got " + (pk == null ? "[Not Found!]" : "[alg:" + pk.getAlgorithm() + ";format:" + pk.getFormat() + "]"), module); + } return pk; } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java Sun Dec 17 16:57:56 2017 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import org.apache.ofbiz.base.lang.Thread /** Basic assertions. The static methods in this class provide a convenient way * to test method arguments. All of the methods in this class throw <code> * IllegalArgumentException</code> if the method arguments are invalid. - * + * */ @ThreadSafe public class Assert { @@ -33,7 +33,7 @@ public class Assert { /** * Tests if an argument is not null and can be cast to a specified class. * <p><code>Assert.isAssignableTo("foo", foo, Foo.class);</code></p> - * + * * @param argumentName * @param argumentObject * @param targetClass @@ -49,7 +49,7 @@ public class Assert { /** * Tests if an argument is not null and is an instance of a specified class. * <p><code>Assert.isInstanceOf("foo", foo, Foo.class);</code></p> - * + * * @param argumentName * @param argumentObject * @param targetClass @@ -65,7 +65,7 @@ public class Assert { /** * Tests if an argument is not null and is an instance of one of the specified classes. * <p><code>Assert.isInstanceOf("foo", foo, Foo.class, Bar.class, ...);</code></p> - * + * * @param argumentName * @param argumentObject * @param targetClasses @@ -92,7 +92,7 @@ public class Assert { /** * Tests if an argument is not null and is not an instance of a specified class. * <p><code>Assert.isNotInstanceOf("foo", foo, Foo.class);</code></p> - * + * * @param argumentName * @param argumentObject * @param targetClass @@ -108,7 +108,7 @@ public class Assert { /** * Tests if an argument is not null and is not an instance of one of the specified classes. * <p><code>Assert.isNotInstanceOf("foo", foo, Foo.class, Bar.class, ...);</code></p> - * + * * @param argumentName * @param argumentObject * @param targetClasses @@ -127,7 +127,7 @@ public class Assert { /** * Tests if an argument is not null and is not empty. * <p><code>Assert.notEmpty("foo", foo);</code></p> - * + * * @param argumentName * @param argumentObject * @throws IllegalArgumentException @@ -142,7 +142,7 @@ public class Assert { /** * Tests if an argument is not null and is not empty. * <p><code>Assert.notEmpty("foo", foo);</code></p> - * + * * @param argumentName * @param argumentObject * @throws IllegalArgumentException @@ -157,7 +157,7 @@ public class Assert { /** * Tests if an argument is not null and is not empty. * <p><code>Assert.notEmpty("foo", foo);</code></p> - * + * * @param argumentName * @param argumentObject * @throws IllegalArgumentException @@ -172,7 +172,7 @@ public class Assert { /** * Tests if an argument is not null and is not empty. * <p><code>Assert.notEmpty("foo", foo);</code></p> - * + * * @param argumentName * @param argumentObject * @throws IllegalArgumentException @@ -187,7 +187,7 @@ public class Assert { /** * Tests a list of arguments for <code>null</code>. * <p><code>Assert.notNull("foo", foo, "bar", bar, ...);</code></p> - * + * * @param arguments * @throws IllegalArgumentException */ @@ -200,7 +200,7 @@ public class Assert { /** * Tests an argument for <code>null</code>. * <p><code>Assert.notNull("foo", foo);</code></p> - * + * * @param argumentName * @param objectToTest * @throws IllegalArgumentException Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java Sun Dec 17 16:57:56 2017 @@ -150,7 +150,9 @@ public class Base64 { * @return the decoded str. */ public final static String base64Decode(String str) { - if (str == null) return null; + if (str == null) { + return null; + } return new String(base64Decode(str.getBytes(UtilIO.getUtf8()))); } @@ -182,8 +184,9 @@ public class Base64 { if (sidx < data.length - 1) { dest[didx++] = base64EncMap[(data[sidx + 1] >>> 4) & 017 | (data[sidx] << 4) & 077]; dest[didx++] = base64EncMap[(data[sidx + 1] << 2) & 077]; - } else + } else { dest[didx++] = base64EncMap[(data[sidx] << 4) & 077]; + } } // add padding Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java Sun Dec 17 16:57:56 2017 @@ -49,7 +49,7 @@ public final class Debug { private static final String[] levelProps = {"", "print.verbose", "print.timing", "print.info", "print.important", "print.warning", "print.error", "print.fatal"}; private static final Level[] levelObjs = {Level.FATAL, Level.DEBUG, Level.TRACE, Level.INFO, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL}; - private static final Map<String, Integer> levelStringMap = new HashMap<String, Integer>(); + private static final Map<String, Integer> levelStringMap = new HashMap<>(); private static final boolean levelOnCache[] = new boolean[8]; // this field is not thread safe @@ -79,14 +79,15 @@ public final class Debug { public static Logger getLogger(String module) { if (UtilValidate.isNotEmpty(module)) { return LogManager.getLogger(module); - } else { - return root; } + return root; } /** Gets an Integer representing the level number from a String representing the level name; will return null if not found */ public static Integer getLevelFromString(String levelName) { - if (levelName == null) return null; + if (levelName == null) { + return null; + } return levelStringMap.get(levelName.toLowerCase(Locale.getDefault())); } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java Sun Dec 17 16:57:56 2017 @@ -25,8 +25,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStreamReader; @@ -55,8 +53,8 @@ public final class FileUtil { private static class SearchTextFilesFilter implements FilenameFilter { String fileExtension; - Set<String> stringsToFindInFile = new HashSet<String>(); - Set<String> stringsToFindInPath = new HashSet<String>(); + Set<String> stringsToFindInFile = new HashSet<>(); + Set<String> stringsToFindInPath = new HashSet<>(); public SearchTextFilesFilter(String fileExtension, Set<String> stringsToFindInPath, Set<String> stringsToFindInFile) { this.fileExtension = fileExtension; @@ -94,9 +92,6 @@ public final class FileUtil { StringBuffer xmlFileBuffer = null; try { xmlFileBuffer = FileUtil.readTextFile(file, true); - } catch (FileNotFoundException e) { - Debug.logWarning("Error reading xml file [" + file + "] for file search: " + e.toString(), module); - return false; } catch (IOException e) { Debug.logWarning("Error reading xml file [" + file + "] for file search: " + e.toString(), module); return false; @@ -149,7 +144,7 @@ public final class FileUtil { writeString(null, fileName, s); } - public static void writeString(String path, String name, String s) throws IOException { + public static void writeString(String path, String name, String s) { try ( Writer out = getBufferedWriter(path, name); @@ -297,8 +292,8 @@ public final class FileUtil { basePath = System.getProperty("ofbiz.home"); } - Set<String> stringsToFindInPath = new HashSet<String>(); - Set<String> stringsToFindInFile = new HashSet<String>(); + Set<String> stringsToFindInPath = new HashSet<>(); + Set<String> stringsToFindInFile = new HashSet<>(); if (partialPath != null) { stringsToFindInPath.add(partialPath); @@ -307,7 +302,7 @@ public final class FileUtil { stringsToFindInFile.add(stringToFind); } - List<File> fileList = new LinkedList<File>(); + List<File> fileList = new LinkedList<>(); FileUtil.searchFiles(fileList, new File(basePath), new SearchTextFilesFilter(fileExt, stringsToFindInPath, stringsToFindInFile), true); return fileList; @@ -318,14 +313,20 @@ public final class FileUtil { basePath = System.getProperty("ofbiz.home"); } - Set<String> stringsToFindInPath = new HashSet<String>(); - Set<String> stringsToFindInFile = new HashSet<String>(); + Set<String> stringsToFindInPath = new HashSet<>(); + Set<String> stringsToFindInFile = new HashSet<>(); - if (partialPath != null) stringsToFindInPath.add(partialPath); - if (rootElementName != null) stringsToFindInFile.add("<" + rootElementName + " "); - if (xsdOrDtdName != null) stringsToFindInFile.add(xsdOrDtdName); + if (partialPath != null) { + stringsToFindInPath.add(partialPath); + } + if (rootElementName != null) { + stringsToFindInFile.add("<" + rootElementName + " "); + } + if (xsdOrDtdName != null) { + stringsToFindInFile.add(xsdOrDtdName); + } - List<File> fileList = new LinkedList<File>(); + List<File> fileList = new LinkedList<>(); FileUtil.searchFiles(fileList, new File(basePath), new SearchTextFilesFilter("xml", stringsToFindInPath, stringsToFindInFile), true); return fileList; } @@ -348,9 +349,14 @@ public final class FileUtil { int count = 0; while((numCharsRead = reader.read(buffer)) > 0) { for (int c = 0; c < numCharsRead; ++c) { - if (buffer[c] == searchString.charAt(count)) count++; - else count = 0; - if (count == searchString.length()) return true; + if (buffer[c] == searchString.charAt(count)) { + count++; + } else { + count = 0; + } + if (count == searchString.length()) { + return true; + } } } return false; @@ -377,9 +383,8 @@ public final class FileUtil { ) { return containsString(in, searchString); } - } else { - return false; } + return false; } /** @@ -396,5 +401,4 @@ public final class FileUtil { File f = new File(fileName); return f.isFile(); } - } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java Sun Dec 17 16:57:56 2017 @@ -34,9 +34,15 @@ public class GeneralException extends Ex } public static <T> T checkException(String message, Throwable t) throws GeneralException { - if (t instanceof Error) throw (Error) t; - if (t instanceof RuntimeException) throw (RuntimeException) t; - if (t instanceof GeneralException) throw (GeneralException) t; + if (t instanceof Error) { + throw (Error) t; + } + if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } + if (t instanceof GeneralException) { + throw (GeneralException) t; + } throw (GeneralException) new GeneralException(message).initCause(t); } @@ -117,12 +123,10 @@ public class GeneralException extends Ex if (nested != null) { if (super.getMessage() == null) { return nested.getMessage(); - } else { - return super.getMessage() + " (" + nested.getMessage() + ")"; } - } else { - return super.getMessage(); + return super.getMessage() + " (" + nested.getMessage() + ")"; } + return super.getMessage(); } public List<String> getMessageList() { Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java Sun Dec 17 16:57:56 2017 @@ -66,10 +66,10 @@ public class GeneralRuntimeException ext /** Returns the detail message, including the message from the nested exception if there is one. */ @Override public String getMessage() { - if (nested != null) + if (nested != null) { return super.getMessage() + " (" + nested.getMessage() + ")"; - else - return super.getMessage(); + } + return super.getMessage(); } /** Returns the detail message, NOT including the message from the nested exception. */ @@ -86,20 +86,26 @@ public class GeneralRuntimeException ext @Override public void printStackTrace() { super.printStackTrace(); - if (nested != null) nested.printStackTrace(); + if (nested != null) { + nested.printStackTrace(); + } } /** Prints the composite message and the embedded stack trace to the specified stream ps. */ @Override public void printStackTrace(PrintStream ps) { super.printStackTrace(ps); - if (nested != null) nested.printStackTrace(ps); + if (nested != null) { + nested.printStackTrace(ps); + } } /** Prints the composite message and the embedded stack trace to the specified print writer pw. */ @Override public void printStackTrace(PrintWriter pw) { super.printStackTrace(pw); - if (nested != null) nested.printStackTrace(pw); + if (nested != null) { + nested.printStackTrace(pw); + } } } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java Sun Dec 17 16:57:56 2017 @@ -64,7 +64,7 @@ public class GroovyUtil { */ try { GroovyUtil.runScriptAtLocation("component://base/config/GroovyInit.groovy", null, null); - } catch(Exception e) { + } catch (Exception e) { Debug.logWarning("The following error occurred during the initialization of Groovy: " + e.getMessage(), module); } } @@ -114,19 +114,22 @@ public class GroovyUtil { * back to the caller. Any variables that are created in the script * are lost when the script ends unless they are copied to the * "context" <code>Map</code>.</p> - * + * * @param context A <code>Map</code> containing initial variables * @return A <code>Binding</code> instance */ public static Binding getBinding(Map<String, Object> context, String expression) { - Map<String, Object> vars = new HashMap<String, Object>(); + Map<String, Object> vars = new HashMap<>(); if (context != null) { vars.putAll(context); if (UtilValidate.isNotEmpty(expression)) { //analyse expression to find variables by split non alpha, ignoring "_" to allow my_variable usage String [] variables = expression.split("[\\P{Alpha}&&[^_]]+"); - for (String variable: variables) - if(!vars.containsKey(variable)) vars.put(variable, null); + for (String variable: variables) { + if(!vars.containsKey(variable)) { + vars.put(variable, null); + } + } } vars.put("context", context); if (vars.get(ScriptUtil.SCRIPT_HELPER_KEY) == null) { Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java Sun Dec 17 16:57:56 2017 @@ -144,8 +144,9 @@ public class HttpClient { /** Set an individual parameter for this request. */ public void setParameter(String name, String value) { - if (parameters == null) - parameters = new HashMap<String, Object>(); + if (parameters == null) { + parameters = new HashMap<>(); + } parameters.put(name, value); } @@ -156,8 +157,9 @@ public class HttpClient { /** Set an individual header for this request. */ public void setHeader(String name, String value) { - if (headers == null) - headers = new HashMap<String, String>(); + if (headers == null) { + headers = new HashMap<>(); + } headers.put(name, value); } @@ -185,12 +187,12 @@ public class HttpClient { public String getContentType() { return this.contentType; } - + /** Sets the scream charset */ public void setStreamCharset(String streamCharset) { this.streamCharset = streamCharset; } - + /** Returns the stream charset */ public String getStreamCharset() { return this.streamCharset; @@ -340,13 +342,15 @@ public class HttpClient { public String sendHttpRequest(String method) throws HttpClientException { InputStream in = sendHttpRequestStream(method); - if (in == null) return null; + if (in == null) { + return null; + } StringBuilder buf = new StringBuilder(); try { if (Debug.verboseOn() || debug) { try { - Debug.logInfo("ContentEncoding: " + con.getContentEncoding() + "; ContentType: " + + Debug.logVerbose("ContentEncoding: " + con.getContentEncoding() + "; ContentType: " + con.getContentType() + " or: " + URLConnection.guessContentTypeFromStream(in), module); } catch (IOException ioe) { Debug.logWarning(ioe, "Caught exception printing content debugging information", module); @@ -359,11 +363,15 @@ public class HttpClient { try { contentType = URLConnection.guessContentTypeFromStream(in); } catch (IOException ioe) { - Debug.logWarning(ioe, "Problems guessing content type from steam", module); + if (Debug.warningOn()) { + Debug.logWarning(ioe, "Problems guessing content type from stream", module); + } } } - if (Debug.verboseOn() || debug) Debug.logVerbose("Content-Type: " + contentType, module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Content-Type: " + contentType, module); + } if (contentType != null) { contentType = contentType.toUpperCase(Locale.getDefault()); @@ -375,8 +383,12 @@ public class HttpClient { charset = contentType.substring(charsetEqualsLoc + 1); } - if (charset != null) charset = charset.trim().replaceAll("\"", ""); - if (Debug.verboseOn() || debug) Debug.logVerbose("Getting text from HttpClient with charset: " + charset, module); + if (charset != null) { + charset = charset.trim().replaceAll("\"", ""); + } + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Getting text from HttpClient with charset: " + charset, module); + } } try ( @@ -384,9 +396,13 @@ public class HttpClient { : new InputStreamReader(in, charset))) { String line = ""; - if (Debug.verboseOn() || debug) Debug.logVerbose("---- HttpClient Response Content ----", module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("---- HttpClient Response Content ----", module); + } while ((line = post.readLine()) != null) { - if (Debug.verboseOn() || debug) Debug.logVerbose("[HttpClient] : " + line, module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("[HttpClient] : " + line, module); + } buf.append(line); if (lineFeed) { buf.append("\n"); @@ -439,11 +455,15 @@ public class HttpClient { } else { con = URLConnector.openConnection(requestUrl, timeout, clientCertAlias, hostVerification); } - if (Debug.verboseOn() || debug) Debug.logVerbose("Connection opened to : " + requestUrl.toExternalForm(), module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Connection opened to : " + requestUrl.toExternalForm(), module); + } if ((con instanceof HttpURLConnection)) { ((HttpURLConnection) con).setInstanceFollowRedirects(followRedirects); - if (Debug.verboseOn() || debug) Debug.logVerbose("Connection is of type HttpURLConnection, more specifically: " + con.getClass().getName(), module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Connection is of type HttpURLConnection, more specifically: " + con.getClass().getName(), module); + } } // set the content type @@ -469,7 +489,9 @@ public class HttpClient { if (basicAuthUsername != null) { String basicAuthString = "Basic " + Base64.base64Encode(basicAuthUsername + ":" + (basicAuthPassword == null ? "" : basicAuthPassword)); con.setRequestProperty("Authorization", basicAuthString); - if (Debug.verboseOn() || debug) Debug.logVerbose("Header - Authorization: " + basicAuthString, module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Header - Authorization: " + basicAuthString, module); + } } if (UtilValidate.isNotEmpty(headers)) { @@ -477,7 +499,9 @@ public class HttpClient { String headerName = entry.getKey(); String headerValue = entry.getValue(); con.setRequestProperty(headerName, headerValue); - if (Debug.verboseOn() || debug) Debug.logVerbose("Header - " + headerName + ": " + headerValue, module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Header - " + headerName + ": " + headerValue, module); + } } } @@ -485,17 +509,20 @@ public class HttpClient { try ( OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream(), this.streamCharset != null ? this.streamCharset : "UTF-8")) { - if (Debug.verboseOn() || debug) - if (Debug.verboseOn()) Debug.logVerbose("Opened output stream", module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Opened output stream", module); + } if (arguments != null) { out.write(arguments); - if (Debug.verboseOn() || debug) - if (Debug.verboseOn()) Debug.logVerbose("Wrote arguements (parameters) : " + arguments, module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Wrote arguements (parameters) : " + arguments, module); + } } - if (Debug.verboseOn() || debug) - if (Debug.verboseOn()) Debug.logVerbose("Flushed and closed buffer", module); + if (Debug.verboseOn() || debug) { + Debug.logVerbose("Flushed and closed buffer", module); + } } } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java Sun Dec 17 16:57:56 2017 @@ -73,14 +73,16 @@ public class HttpRequestFileUpload { } public String getFieldValue(String fieldName) { - if (fields == null || fieldName == null) + if (fields == null || fieldName == null) { return null; + } return fields.get(fieldName); } private void setFilename(String s) { - if (s == null) + if (s == null) { return; + } int pos = s.indexOf("filename=\""); @@ -90,21 +92,24 @@ public class HttpRequestFileUpload { // But Linux/Unix and Mac browsers only send the filename // test if this is from a Windows browser pos = filepath.lastIndexOf("\\"); - if (pos != -1) + if (pos != -1) { filename = filepath.substring(pos + 1); - else + } else { filename = filepath; + } } } private void setContentType(String s) { - if (s == null) + if (s == null) { return; + } int pos = s.indexOf(": "); - if (pos != -1) + if (pos != -1) { contentType = s.substring(pos + 2, s.length()); + } } public void doUpload(HttpServletRequest request) throws IOException { @@ -127,14 +132,15 @@ public class HttpRequestFileUpload { i = waitingReadLine(in, line, 0, BUFFER_SIZE, requestLength); requestLength -= i; - if (i < 3) + if (i < 3) { return; + } int boundaryLength = i - 2; String boundary = new String(line, 0, boundaryLength, UtilIO.getUtf8()); // -2 discards the newline character System.out.println("boundary=[" + boundary + "] length is " + boundaryLength); - fields = new HashMap<String, String>(); + fields = new HashMap<>(); while (requestLength > 0/* i != -1*/) { String newLine = ""; @@ -145,8 +151,9 @@ public class HttpRequestFileUpload { if (newLine.startsWith("Content-Disposition: form-data; name=\"")) { if (newLine.indexOf("filename=\"") != -1) { setFilename(new String(line, 0, i - 2, UtilIO.getUtf8())); - if (filename == null) + if (filename == null) { return; + } // this is the file content i = waitingReadLine(in, line, 0, BUFFER_SIZE, requestLength); requestLength -= i; @@ -252,10 +259,11 @@ public class HttpRequestFileUpload { i = waitingReadLine(in, line, 0, BUFFER_SIZE, requestLength); requestLength -= i; if ((i == boundaryLength + 2 || i == boundaryLength + 4) // + 4 is eof - && (new String(line, 0, i).startsWith(boundary))) + && (new String(line, 0, i).startsWith(boundary))) { fieldValue.append(newLine.substring(0, newLine.length() - 2)); - else + } else { fieldValue.append(newLine); + } newLine = new String(line, 0, i, UtilIO.getUtf8()); } fields.put(fieldName, fieldValue.toString()); Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java Sun Dec 17 16:57:56 2017 @@ -47,7 +47,9 @@ public class IndentingWriter extends Fil public IndentingWriter newline() throws IOException { lastWasNewline = true; - if (doNewline) super.write('\n'); + if (doNewline) { + super.write('\n'); + } return this; } @@ -76,7 +78,9 @@ public class IndentingWriter extends Fil public IndentingWriter space() throws IOException { checkAfterNewline(); - if (doSpace) super.write(' '); + if (doSpace) { + super.write(' '); + } return this; } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java Sun Dec 17 16:57:56 2017 @@ -55,17 +55,20 @@ public class JNDIContextFactory { if (UtilValidate.isEmpty(jndiServerInfo.contextProviderUrl)) { ic = new InitialContext(); } else { - Hashtable<String, Object> h = new Hashtable<String, Object>(); + Hashtable<String, Object> h = new Hashtable<>(); h.put(Context.INITIAL_CONTEXT_FACTORY, jndiServerInfo.initialContextFactory); h.put(Context.PROVIDER_URL, jndiServerInfo.contextProviderUrl); - if (UtilValidate.isNotEmpty(jndiServerInfo.urlPkgPrefixes)) + if (UtilValidate.isNotEmpty(jndiServerInfo.urlPkgPrefixes)) { h.put(Context.URL_PKG_PREFIXES, jndiServerInfo.urlPkgPrefixes); + } - if (UtilValidate.isNotEmpty(jndiServerInfo.securityPrincipal)) + if (UtilValidate.isNotEmpty(jndiServerInfo.securityPrincipal)) { h.put(Context.SECURITY_PRINCIPAL, jndiServerInfo.securityPrincipal); - if (UtilValidate.isNotEmpty(jndiServerInfo.securityCredentials)) + } + if (UtilValidate.isNotEmpty(jndiServerInfo.securityCredentials)) { h.put(Context.SECURITY_CREDENTIALS, jndiServerInfo.securityCredentials); + } ic = new InitialContext(h); } @@ -88,5 +91,4 @@ public class JNDIContextFactory { public static void clearInitialContext(String jndiServerName) { contexts.remove(jndiServerName); } - } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java Sun Dec 17 16:57:56 2017 @@ -31,7 +31,6 @@ import java.io.PrintStream; import java.io.Reader; import java.io.StringReader; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.KeyFactory; import java.security.KeyStore; @@ -145,7 +144,7 @@ public final class KeyStoreUtil { } public static Map<String, String> getX500Map(Principal x500) { - Map<String, String> x500Map = new HashMap<String, String>(); + Map<String, String> x500Map = new HashMap<>(); String name = x500.getName().replaceAll("\\\\,", "&com;"); String[] x500Opts = name.split("\\,"); Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java Sun Dec 17 16:57:56 2017 @@ -48,23 +48,31 @@ public class MessageString implements Se if (fieldName == null) { return Collections.emptyList(); } - Set<String> fieldSet = new TreeSet<String>(); + Set<String> fieldSet = new TreeSet<>(); fieldSet.add(fieldName); return getMessagesForField(fieldSet, convertToStrings, messageStringList); } public static List<Object> getMessagesForField(String fieldName1, String fieldName2, String fieldName3, String fieldName4, boolean convertToStrings, List<Object> messageStringList) { - Set<String> fieldSet = new TreeSet<String>(); - if (UtilValidate.isNotEmpty(fieldName1)) fieldSet.add(fieldName1); - if (UtilValidate.isNotEmpty(fieldName2)) fieldSet.add(fieldName2); - if (UtilValidate.isNotEmpty(fieldName3)) fieldSet.add(fieldName3); - if (UtilValidate.isNotEmpty(fieldName4)) fieldSet.add(fieldName4); + Set<String> fieldSet = new TreeSet<>(); + if (UtilValidate.isNotEmpty(fieldName1)) { + fieldSet.add(fieldName1); + } + if (UtilValidate.isNotEmpty(fieldName2)) { + fieldSet.add(fieldName2); + } + if (UtilValidate.isNotEmpty(fieldName3)) { + fieldSet.add(fieldName3); + } + if (UtilValidate.isNotEmpty(fieldName4)) { + fieldSet.add(fieldName4); + } return getMessagesForField(fieldSet, convertToStrings, messageStringList); } public static List<Object> getMessagesForField(Set<String> fieldNameSet, boolean convertToStrings, List<Object> messageStringList) { if (messageStringList == null || UtilValidate.isEmpty(fieldNameSet)) { return Collections.emptyList(); } - List<Object> outList = new ArrayList<Object>(messageStringList.size()); + List<Object> outList = new ArrayList<>(messageStringList.size()); for (Object messageStringCur: messageStringList) { if (messageStringCur instanceof MessageString) { MessageString messageString = (MessageString) messageStringCur; @@ -152,12 +160,10 @@ public class MessageString implements Se if (this.fieldName == null) { if (fieldName == null) { return true; - } else { - return false; } - } else { - return this.fieldName.equals(fieldName); + return false; } + return this.fieldName.equals(fieldName); } /** Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java Sun Dec 17 16:57:56 2017 @@ -45,7 +45,7 @@ public class MultiTrustManager implement } public MultiTrustManager() { - keystores = new LinkedList<KeyStore>(); + keystores = new LinkedList<>(); } public void add(KeyStore ks) { @@ -77,7 +77,7 @@ public class MultiTrustManager implement } public X509Certificate[] getAcceptedIssuers() { - List<X509Certificate> issuers = new LinkedList<X509Certificate>(); + List<X509Certificate> issuers = new LinkedList<>(); for (KeyStore store: keystores) { try { Enumeration<String> e = store.aliases(); @@ -87,16 +87,18 @@ public class MultiTrustManager implement if (chain != null) { for (Certificate cert: chain) { if (cert instanceof X509Certificate) { - if (Debug.verboseOn()) - Debug.logInfo("Read certificate (chain) : " + ((X509Certificate) cert).getSubjectX500Principal().getName(), module); + if (Debug.verboseOn()) { + Debug.logVerbose("Read certificate (chain) : " + ((X509Certificate) cert).getSubjectX500Principal().getName(), module); + } issuers.add((X509Certificate) cert); } } } else { Certificate cert = store.getCertificate(alias); if (cert != null && cert instanceof X509Certificate) { - if (Debug.verboseOn()) - Debug.logInfo("Read certificate : " + ((X509Certificate) cert).getSubjectX500Principal().getName(), module); + if (Debug.verboseOn()) { + Debug.logVerbose("Read certificate : " + ((X509Certificate) cert).getSubjectX500Principal().getName(), module); + } issuers.add((X509Certificate) cert); } } @@ -114,11 +116,13 @@ public class MultiTrustManager implement X509Certificate[] issuers = this.getAcceptedIssuers(); for (X509Certificate issuer: issuers) { for (X509Certificate c: cert) { - if (Debug.verboseOn()) - Debug.logInfo("--- Checking cert: " + issuer.getSubjectX500Principal() + " vs " + c.getSubjectX500Principal(), module); + if (Debug.verboseOn()) { + Debug.logVerbose("--- Checking cert: " + issuer.getSubjectX500Principal() + " vs " + c.getSubjectX500Principal(), module); + } if (issuer.equals(c)) { - if (Debug.verboseOn()) - Debug.logInfo("--- Found trusted cert: " + issuer.getSerialNumber().toString(16) + " : " + issuer.getSubjectX500Principal(), module); + if (Debug.verboseOn()) { + Debug.logVerbose("--- Found trusted cert: " + issuer.getSerialNumber().toString(16) + " : " + issuer.getSubjectX500Principal(), module); + } return true; } } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectInputStream.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectInputStream.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectInputStream.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectInputStream.java Sun Dec 17 16:57:56 2017 @@ -50,8 +50,9 @@ public class ObjectInputStream extends j @Override protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class<?>[] cinterfaces = new Class[interfaces.length]; - for (int i = 0; i < interfaces.length; i++) + for (int i = 0; i < interfaces.length; i++) { cinterfaces[i] = classloader.loadClass(interfaces[i]); + } try { return Proxy.getProxyClass(classloader, cinterfaces); Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java Sun Dec 17 16:57:56 2017 @@ -21,7 +21,6 @@ package org.apache.ofbiz.base.util; import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -50,8 +49,8 @@ public class ObjectType { public static final String LANG_PACKAGE = "java.lang."; // We will test both the raw value and this + raw value public static final String SQL_PACKAGE = "java.sql."; // We will test both the raw value and this + raw value - private static final Map<String, String> classAlias = new HashMap<String, String>(); - private static final Map<String, Class<?>> primitives = new HashMap<String, Class<?>>(); + private static final Map<String, String> classAlias = new HashMap<>(); + private static final Map<String, Class<?>> primitives = new HashMap<>(); static { classAlias.put("Object", "java.lang.Object"); @@ -114,7 +113,9 @@ public class ObjectType { } int genericsStart = className.indexOf("<"); - if (genericsStart != -1) className = className.substring(0, genericsStart); + if (genericsStart != -1) { + className = className.substring(0, genericsStart); + } // Handle array classes. Details in http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/types.html#wp16437 if (className.endsWith("[]")) { @@ -138,7 +139,9 @@ public class ObjectType { className = classAlias.get(className); } - if (loader == null) loader = Thread.currentThread().getContextClassLoader(); + if (loader == null) { + loader = Thread.currentThread().getContextClassLoader(); + } theClass = Class.forName(className, true, loader); @@ -159,7 +162,9 @@ public class ObjectType { Class<?> c = loadClass(className); Object o = c.newInstance(); - if (Debug.verboseOn()) Debug.logVerbose("Instantiated object: " + o.toString(), module); + if (Debug.verboseOn()) { + Debug.logVerbose("Instantiated object: " + o.toString(), module); + } return o; } @@ -207,7 +212,9 @@ public class ObjectType { Constructor<?> con = c.getConstructor(sig); Object o = con.newInstance(parameters); - if (Debug.verboseOn()) Debug.logVerbose("Instantiated object: " + o.toString(), module); + if (Debug.verboseOn()) { + Debug.logVerbose("Instantiated object: " + o.toString(), module); + } return o; } @@ -259,7 +266,9 @@ public class ObjectType { Class<?>[] ifaces = objectClass.getInterfaces(); for (Class<?> iface: ifaces) { - if (iface == interfaceClass) return true; + if (iface == interfaceClass) { + return true; + } } objectClass = objectClass.getSuperclass(); } @@ -336,7 +345,9 @@ public class ObjectType { */ public static boolean isOrSubOf(Class<?> objectClass, Class<?> parentClass) { while (objectClass != null) { - if (objectClass == parentClass) return true; + if (objectClass == parentClass) { + return true; + } objectClass = objectClass.getSuperclass(); } return false; @@ -396,8 +407,9 @@ public class ObjectType { public static boolean instanceOf(Class<?> objectClass, String typeName, ClassLoader loader) { Class<?> infoClass = loadInfoClass(typeName, loader); - if (infoClass == null) + if (infoClass == null) { throw new IllegalArgumentException("Illegal type found in info map (could not load class for specified type)"); + } return instanceOf(objectClass, infoClass); } @@ -453,7 +465,9 @@ public class ObjectType { * @return true if obj is an instance of a sub-class of typeClass */ public static boolean instanceOf(Object obj, Class<?> typeClass) { - if (obj == null) return true; + if (obj == null) { + return true; + } Class<?> objectClass = obj.getClass(); return instanceOf(objectClass, typeClass); } @@ -467,9 +481,8 @@ public class ObjectType { public static boolean instanceOf(Class<?> objectClass, Class<?> typeClass) { if (typeClass.isInterface() && !objectClass.isInterface()) { return interfaceOf(objectClass, typeClass); - } else { - return isOrSubOf(objectClass, typeClass); } + return isOrSubOf(objectClass, typeClass); } public static Object simpleTypeConvert(Object obj, String type, String format, Locale locale, boolean noTypeFail) throws GeneralException { @@ -503,9 +516,8 @@ public class ObjectType { String nodeValue = node.getTextContent(); if ("String".equals(type) || "java.lang.String".equals(type)) { return nodeValue; - } else { - return simpleTypeConvert(nodeValue, type, format, timeZone, locale, noTypeFail); } + return simpleTypeConvert(nodeValue, type, format, timeZone, locale, noTypeFail); } int genericsStart = type.indexOf("<"); if (genericsStart != -1) { @@ -562,10 +574,11 @@ public class ObjectType { } if (noTypeFail) { throw new GeneralException("Conversion from " + obj.getClass().getName() + " to " + type + " not currently supported"); - } else { - if (Debug.infoOn()) Debug.logInfo("No type conversion available for " + obj.getClass().getName() + " to " + targetClass.getName() + ", returning original object.", module); - return obj; } + if (Debug.infoOn()) { + Debug.logInfo("No type conversion available for " + obj.getClass().getName() + " to " + targetClass.getName() + ", returning original object.", module); + } + return obj; } public static Object simpleTypeConvert(Object obj, String type, String format, Locale locale) throws GeneralException { @@ -576,7 +589,9 @@ public class ObjectType { List<Object> messages, Locale locale, ClassLoader loader, boolean value2InlineConstant) { boolean verboseOn = Debug.verboseOn(); - if (verboseOn) Debug.logVerbose("Comparing value1: \"" + value1 + "\" " + operator + " value2:\"" + value2 + "\"", module); + if (verboseOn) { + Debug.logVerbose("Comparing value1: \"" + value1 + "\" " + operator + " value2:\"" + value2 + "\"", module); + } try { if (!"PlainString".equals(type)) { @@ -660,29 +675,36 @@ public class ObjectType { String str2 = (String) convertedValue2; return str1.indexOf(str2) < 0 ? Boolean.FALSE : Boolean.TRUE; - } else { - messages.add("Error in XML file: cannot do a contains compare between a String and a non-String type"); - return null; } + messages.add("Error in XML file: cannot do a contains compare between a String and a non-String type"); + return null; } else if ("is-empty".equals(operator)) { - if (convertedValue1 == null) + if (convertedValue1 == null) { return Boolean.TRUE; - if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0) + } + if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0) { return Boolean.TRUE; - if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0) + } + if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0) { return Boolean.TRUE; - if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0) + } + if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0) { return Boolean.TRUE; + } return Boolean.FALSE; } else if ("is-not-empty".equals(operator)) { - if (convertedValue1 == null) + if (convertedValue1 == null) { return Boolean.FALSE; - if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0) + } + if (convertedValue1 instanceof String && ((String) convertedValue1).length() == 0) { return Boolean.FALSE; - if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0) + } + if (convertedValue1 instanceof List<?> && ((List<?>) convertedValue1).size() == 0) { return Boolean.FALSE; - if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0) + } + if (convertedValue1 instanceof Map<?, ?> && ((Map<?, ?>) convertedValue1).size() == 0) { return Boolean.FALSE; + } return Boolean.TRUE; } @@ -708,12 +730,13 @@ public class ObjectType { tempNum = (Number) convertedValue2; double value2Double = tempNum.doubleValue(); - if (value1Double < value2Double) + if (value1Double < value2Double) { result = -1; - else if (value1Double > value2Double) + } else if (value1Double > value2Double) { result = 1; - else + } else { result = 0; + } } else if ("java.sql.Date".equals(type)) { java.sql.Date value1Date = (java.sql.Date) convertedValue1; java.sql.Date value2Date = (java.sql.Date) convertedValue2; @@ -730,15 +753,17 @@ public class ObjectType { Boolean value1Boolean = (Boolean) convertedValue1; Boolean value2Boolean = (Boolean) convertedValue2; if ("equals".equals(operator)) { - if ((value1Boolean.booleanValue() && value2Boolean.booleanValue()) || (!value1Boolean.booleanValue() && !value2Boolean.booleanValue())) + if ((value1Boolean.booleanValue() && value2Boolean.booleanValue()) || (!value1Boolean.booleanValue() && !value2Boolean.booleanValue())) { result = 0; - else + } else { result = 1; + } } else if ("not-equals".equals(operator)) { - if ((!value1Boolean.booleanValue() && value2Boolean.booleanValue()) || (value1Boolean.booleanValue() && !value2Boolean.booleanValue())) + if ((!value1Boolean.booleanValue() && value2Boolean.booleanValue()) || (value1Boolean.booleanValue() && !value2Boolean.booleanValue())) { result = 0; - else + } else { result = 1; + } } else { messages.add("Can only compare Booleans using the operators 'equals' or 'not-equals'"); return null; @@ -754,50 +779,80 @@ public class ObjectType { return null; } - if (verboseOn) Debug.logVerbose("Got Compare result: " + result + ", operator: " + operator, module); + if (verboseOn) { + Debug.logVerbose("Got Compare result: " + result + ", operator: " + operator, module); + } if ("less".equals(operator)) { - if (result >= 0) + if (result >= 0) { return Boolean.FALSE; + } } else if ("greater".equals(operator)) { - if (result <= 0) + if (result <= 0) { return Boolean.FALSE; + } } else if ("less-equals".equals(operator)) { - if (result > 0) + if (result > 0) { return Boolean.FALSE; + } } else if ("greater-equals".equals(operator)) { - if (result < 0) + if (result < 0) { return Boolean.FALSE; + } } else if ("equals".equals(operator)) { - if (result != 0) + if (result != 0) { return Boolean.FALSE; + } } else if ("not-equals".equals(operator)) { - if (result == 0) + if (result == 0) { return Boolean.FALSE; + } } else { messages.add("Specified compare operator \"" + operator + "\" not known."); return null; } - if (verboseOn) Debug.logVerbose("Returning true", module); + if (verboseOn) { + Debug.logVerbose("Returning true", module); + } return Boolean.TRUE; } @SuppressWarnings("unchecked") public static boolean isEmpty(Object value) { - if (value == null) return true; + if (value == null) { + return true; + } - if (value instanceof String) return ((String) value).length() == 0; - if (value instanceof Collection) return ((Collection<? extends Object>) value).size() == 0; - if (value instanceof Map) return ((Map<? extends Object, ? extends Object>) value).size() == 0; - if (value instanceof CharSequence) return ((CharSequence) value).length() == 0; - if (value instanceof IsEmpty) return ((IsEmpty) value).isEmpty(); + if (value instanceof String) { + return ((String) value).length() == 0; + } + if (value instanceof Collection) { + return ((Collection<? extends Object>) value).size() == 0; + } + if (value instanceof Map) { + return ((Map<? extends Object, ? extends Object>) value).size() == 0; + } + if (value instanceof CharSequence) { + return ((CharSequence) value).length() == 0; + } + if (value instanceof IsEmpty) { + return ((IsEmpty) value).isEmpty(); + } // These types would flood the log // Number covers: BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short - if (value instanceof Boolean) return false; - if (value instanceof Number) return false; - if (value instanceof Character) return false; - if (value instanceof java.util.Date) return false; + if (value instanceof Boolean) { + return false; + } + if (value instanceof Number) { + return false; + } + if (value instanceof Character) { + return false; + } + if (value instanceof java.util.Date) { + return false; + } if (Debug.verboseOn()) { Debug.logVerbose("In ObjectType.isEmpty(Object value) returning false for " + value.getClass() + " Object.", module); @@ -824,9 +879,8 @@ public class ObjectType { if (other instanceof NullObject) { // should do equality of object? don't think so, just same type return true; - } else { - return false; } + return false; } } } Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observable.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observable.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observable.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observable.java Sun Dec 17 16:57:56 2017 @@ -35,7 +35,7 @@ import java.util.concurrent.atomic.Atomi public final class Observable { private final AtomicBoolean changed = new AtomicBoolean(); - private final CopyOnWriteArrayList<Observer> observers = new CopyOnWriteArrayList<Observer>(); + private final CopyOnWriteArrayList<Observer> observers = new CopyOnWriteArrayList<>(); public Observable() {} @@ -46,7 +46,7 @@ public final class Observable { } /** - * Adds an observer to the set of observers for this object. + * Adds an observer to the set of observers for this object. * * @param observer the observer to be added. */ @@ -56,16 +56,16 @@ public final class Observable { } /** - * Clears the changed flag. + * Clears the changed flag. */ public void clearChanged() { changed.set(false); } /** - * Deletes an observer from the set of observers of this object. + * Deletes an observer from the set of observers of this object. * Passing <code>null</code> to this method will have no effect. - * + * * @param observer the observer to be deleted. */ public void deleteObserver(Observer observer) { @@ -80,7 +80,7 @@ public final class Observable { } /** - * Returns <code>true</code> if this object has changed. + * Returns <code>true</code> if this object has changed. * */ public boolean hasChanged() { @@ -88,9 +88,9 @@ public final class Observable { } /** - * Notify all of the observers. + * Notify all of the observers. * <p>Each <code>Observer</code> has its <code>update</code> method called with two - * arguments: this observable object and <code>null</code>. In other + * arguments: this observable object and <code>null</code>. In other * words, this method is equivalent to: * </p> * <blockquote> @@ -103,7 +103,7 @@ public final class Observable { } /** - * Notify all of the observers. + * Notify all of the observers. * <p>Each observer has its <code>update</code> method called with two * arguments: this observable object and the <code>arg</code> argument.</p> * @@ -115,7 +115,7 @@ public final class Observable { } /** - * Sets the changed flag to <code>true</code>. + * Sets the changed flag to <code>true</code>. */ public void setChanged() { changed.set(true); Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observer.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observer.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observer.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Observer.java Sun Dec 17 16:57:56 2017 @@ -25,7 +25,7 @@ package org.apache.ofbiz.base.util; public interface Observer { /** * Called when <code>Observable.notifyObservers</code> is invoked. - * + * * @param observable * @param arg */ Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java Sun Dec 17 16:57:56 2017 @@ -26,8 +26,8 @@ import java.net.UnknownHostException; import java.rmi.server.RMISocketFactory; /** - * A <code>RMISocketFactory</code> implementation that creates <code>ServerSocket</code>s bound - * on a specified network interface. + * A <code>RMISocketFactory</code> implementation that creates <code>ServerSocket</code>s bound + * on a specified network interface. */ public class RMIExtendedSocketFactory extends RMISocketFactory { @@ -44,21 +44,21 @@ public class RMIExtendedSocketFactory ex } /** - * Creates a new <code>RMIExtendedSocketFactory</code> which will create <code>ServerSocket</code>s - * bound on the specified network interface. - * - * @param inetAddress The <code>InetAddress</code> of the network interface. + * Creates a new <code>RMIExtendedSocketFactory</code> which will create <code>ServerSocket</code>s + * bound on the specified network interface. + * + * @param inetAddress The <code>InetAddress</code> of the network interface. */ public RMIExtendedSocketFactory( InetAddress inetAddress ) { this.hostInetAddress = inetAddress; } /** - * Creates a new <code>RMIExtendedSocketFactory</code> which will create <code>ServerSocket</code>s - * bound on the specified network interface. - * + * Creates a new <code>RMIExtendedSocketFactory</code> which will create <code>ServerSocket</code>s + * bound on the specified network interface. + * * @param hostIpAddress The IP address of the interface to bind the server sockets to. - * @throws UnknownHostException If an invalid IP address is provided. + * @throws UnknownHostException If an invalid IP address is provided. */ public RMIExtendedSocketFactory( String hostIpAddress ) throws UnknownHostException { @@ -89,9 +89,8 @@ public class RMIExtendedSocketFactory ex public ServerSocket createServerSocket(int port) throws IOException { if ( hostInetAddress != null ) { return new ServerSocket( port, 0, hostInetAddress ); - } else { - return new ServerSocket( port ); } + return new ServerSocket( port ); } @Override Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ReferenceCleaner.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ReferenceCleaner.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ReferenceCleaner.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ReferenceCleaner.java Sun Dec 17 16:57:56 2017 @@ -63,7 +63,7 @@ public final class ReferenceCleaner { private ReferenceCleaner() { } - private static final ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>(); + private static final ReferenceQueue<Object> QUEUE = new ReferenceQueue<>(); public interface Removable { void remove() throws Exception; Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/SSLUtil.java Sun Dec 17 16:57:56 2017 @@ -104,11 +104,7 @@ public final class SSLUtil { TrustManager[] mgrs = new TrustManager[0]; try { mgrs = SSLUtil.getTrustManagers(); - } catch (IOException e) { - Debug.logError(e, module); - } catch (GeneralSecurityException e) { - Debug.logError(e, module); - } catch (GenericConfigException e) { + } catch (IOException | GeneralSecurityException | GenericConfigException e) { Debug.logError(e, module); } @@ -126,7 +122,7 @@ public final class SSLUtil { } public static KeyManager[] getKeyManagers(String alias) throws IOException, GeneralSecurityException, GenericConfigException { - List<KeyManager> keyMgrs = new LinkedList<KeyManager>(); + List<KeyManager> keyMgrs = new LinkedList<>(); for (ComponentConfig.KeystoreInfo ksi: ComponentConfig.getAllKeystoreInfos()) { if (ksi.isCertStore()) { KeyStore ks = ksi.getKeyStore(); @@ -190,7 +186,7 @@ public final class SSLUtil { return keyManagers; } - public static TrustManager[] getTrustManagers(KeyStore ks) throws GeneralSecurityException { + public static TrustManager[] getTrustManagers(KeyStore ks) { return new TrustManager[] { new MultiTrustManager(ks) }; } @@ -263,8 +259,9 @@ public final class SSLUtil { Principal x500s = peerCert.getSubjectDN(); Map<String, String> subjectMap = KeyStoreUtil.getX500Map(x500s); - if (Debug.infoOn()) + if (Debug.infoOn()) { Debug.logInfo(peerCert.getSerialNumber().toString(16) + " :: " + subjectMap.get("CN"), module); + } try { peerCert.checkValidity(); Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelper.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelper.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelper.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptHelper.java Sun Dec 17 16:57:56 2017 @@ -37,7 +37,7 @@ public interface ScriptHelper { /** * Extracts service IN parameters from <code>inputMap</code> and returns them in a new <code>Map</code>. - * + * * @param serviceName * @param inputMap * @return The matching service parameters @@ -47,14 +47,14 @@ public interface ScriptHelper { /** * Sets the event/service status to error status. - * + * * @param message */ void error(String message); /** * Evaluates a <code>String</code> and returns the result. - * + * * @param original * @return */ @@ -62,7 +62,7 @@ public interface ScriptHelper { /** * Sets the event/service status to failure status. - * + * * @param message */ void failure(String message); @@ -97,21 +97,21 @@ public interface ScriptHelper { /** * Logs an error message. - * + * * @param message */ void logError(String message); /** * Logs an info message. - * + * * @param message */ void logInfo(String message); /** * Logs a warning message. - * + * * @param message */ void logWarning(String message); @@ -126,7 +126,7 @@ public interface ScriptHelper { /** * Creates a new, empty <code>GenericValue</code>. - * + * * @param entityName * @param fields * @return @@ -136,7 +136,7 @@ public interface ScriptHelper { /** * Runs a service synchronously. - * + * * @param serviceName * @param inputMap * @return @@ -146,7 +146,7 @@ public interface ScriptHelper { /** * Runs a service synchronously. - * + * * @param serviceName * @param inputMap * @param args @@ -162,7 +162,7 @@ public interface ScriptHelper { /** * Sets the event/service status to success status. - * + * * @param message */ void success(String message); Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/ScriptUtil.java Sun Dec 17 16:57:56 2017 @@ -75,7 +75,7 @@ public final class ScriptUtil { public static final Set<String> SCRIPT_NAMES; static { - Set<String> writableScriptNames = new HashSet<String>(); + Set<String> writableScriptNames = new HashSet<>(); ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> engines = manager.getEngineFactories(); if (engines.isEmpty()) { @@ -117,7 +117,7 @@ public final class ScriptUtil { /** * Returns a compiled script. - * + * * @param filePath Script path and file name. * @return The compiled script, or <code>null</code> if the script engine does not support compilation. * @throws IllegalArgumentException @@ -156,7 +156,7 @@ public final class ScriptUtil { /** * Returns a compiled script. - * + * * @param language * @param script * @return The compiled script, or <code>null</code> if the script engine does not support compilation. @@ -196,13 +196,13 @@ public final class ScriptUtil { * <p>If a <code>CompiledScript</code> instance is to be shared by multiple threads, then * each thread must create its own <code>ScriptContext</code> and pass it to the * <code>CompiledScript</code> eval method.</p> - * + * * @param context * @return */ public static ScriptContext createScriptContext(Map<String, Object> context) { Assert.notNull("context", context); - Map<String, Object> localContext = new HashMap<String, Object>(context); + Map<String, Object> localContext = new HashMap<>(context); localContext.put(WIDGET_CONTEXT_KEY, context); localContext.put("context", context); ScriptContext scriptContext = new SimpleScriptContext(); @@ -220,14 +220,14 @@ public final class ScriptUtil { * <p>If a <code>CompiledScript</code> instance is to be shared by multiple threads, then * each thread must create its own <code>ScriptContext</code> and pass it to the * <code>CompiledScript</code> eval method.</p> - * + * * @param context * @param protectedKeys * @return */ public static ScriptContext createScriptContext(Map<String, Object> context, Set<String> protectedKeys) { Assert.notNull("context", context, "protectedKeys", protectedKeys); - Map<String, Object> localContext = new HashMap<String, Object>(context); + Map<String, Object> localContext = new HashMap<>(context); localContext.put(WIDGET_CONTEXT_KEY, context); localContext.put("context", context); ScriptContext scriptContext = new SimpleScriptContext(); @@ -249,7 +249,7 @@ public final class ScriptUtil { /** * Executes a script <code>String</code> and returns the result. - * + * * @param language * @param script * @param scriptClass @@ -286,7 +286,7 @@ public final class ScriptUtil { /** * Executes a compiled script and returns the result. - * + * * @param script Compiled script. * @param functionName Optional function or method to invoke. * @param scriptContext Script execution context. @@ -313,7 +313,7 @@ public final class ScriptUtil { /** * Executes the script at the specified location and returns the result. - * + * * @param filePath Script path and file name. * @param functionName Optional function or method to invoke. * @param context Script execution context. @@ -326,7 +326,7 @@ public final class ScriptUtil { /** * Executes the script at the specified location and returns the result. - * + * * @param filePath Script path and file name. * @param functionName Optional function or method to invoke. * @param context Script execution context. @@ -351,7 +351,7 @@ public final class ScriptUtil { /** * Executes the script at the specified location and returns the result. - * + * * @param filePath Script path and file name. * @param functionName Optional function or method to invoke. * @param scriptContext Script execution context. Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Scriptlet.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Scriptlet.java?rev=1818495&r1=1818494&r2=1818495&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Scriptlet.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/Scriptlet.java Sun Dec 17 16:57:56 2017 @@ -44,7 +44,7 @@ public final class Scriptlet { /** * Executes the scriptlet and returns the result. - * + * * @param context The script bindings * @return The scriptlet result * @throws Exception |
Free forum by Nabble | Edit this page |