From a2278de50e951fad1ef6d3c2f35aefa4b4c289f5 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 17 Aug 2015 09:30:17 +0200 Subject: [PATCH] =?utf8?q?Replace=20multiple-added=20strings/objects=20int?= =?utf8?q?o=20MessageFormat.format()=20call=20to=20reduce=20string=20objec?= =?utf8?q?ts=20in=20string=20pool=20+=20ignored=20them=20for=20internation?= =?utf8?q?alization=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../BasePizzaServiceSystem.java | 16 ++-- .../application/PizzaServiceApplication.java | 46 +++++------ .../category/BaseCategory.java | 34 ++++----- .../PizzaCategoryDatabaseConstants.java | 6 +- .../PizzaCategoryDatabaseFrontend.java | 18 ++--- .../product/PizzaProductDatabaseFrontend.java | 46 +++++------ .../PizzaProductDatabaseConstants.java | 10 +-- .../CategoryTitleAlreadyUsedException.java | 2 +- .../ProductTitleAlreadyUsedException.java | 2 +- .../filter/http/BaseServletFilter.java | 32 ++++---- .../filter/http/utf8/Utf8HttpFilter.java | 4 +- .../pizzaapplication/product/BaseProduct.java | 76 +++++++++---------- .../product/pizza/PizzaProduct.java | 3 +- 13 files changed, 148 insertions(+), 147 deletions(-) diff --git a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java index 031f2f92..27a3f099 100644 --- a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java +++ b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java @@ -32,36 +32,36 @@ public class BasePizzaServiceSystem extends BaseFrameworkSystem { */ protected void initProperties (final ServletContext context) { // Trace message - this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); + this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); //NOI18N // We need some properties that needs to be set for (final String name : this.getPropertyNames()) { // Debug log - this.getLogger().debug(MessageFormat.format("name={0}", name)); + this.getLogger().debug(MessageFormat.format("name={0}", name)); //NOI18N // Get value String value = context.getInitParameter(name); // Debug message - this.getLogger().debug(MessageFormat.format("value={0}", value)); + this.getLogger().debug(MessageFormat.format("value={0}", value)); //NOI18N // Is it null? if (value == null) { // Value is null - throw new NullPointerException(MessageFormat.format("value for {0} is null, maybe invalid context parameter?", name)); - } else if (name.equals("database.backend.storagepath")) { + throw new NullPointerException(MessageFormat.format("value for {0} is null, maybe invalid context parameter?", name)); //NOI18N + } else if (name.equals("database.backend.storagepath")) { //NOI18N // Need to expand this path - value = context.getRealPath(String.format("../../%s", value.trim())); + value = context.getRealPath(String.format("../../%s", value.trim())); //NOI18N } // Debug log - this.getLogger().debug(MessageFormat.format("{0}={1}", name, value)); + this.getLogger().debug(MessageFormat.format("{0}={1}", name, value)); //NOI18N // Set property this.setProperty(name, value); } // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index c74d2592..41629a3e 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -1302,7 +1302,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P String available = request.getParameter(PizzaProductDatabaseConstants.COLUMN_AVAILABLE); // Debug message - this.getLogger().debug(MessageFormat.format("title={0},price={1},category={2},available={3}", title, price, category, available)); + this.getLogger().debug(MessageFormat.format("title={0},price={1},category={2},available={3}", title, price, category, available)); //NOI18N // Variables for converting Long id = null; @@ -1407,12 +1407,12 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P @Override public String getPrintableProduktCategory (final Product product) throws ServletException { // Trace message - this.getLogger().trace("product=" + product + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N // product must not be null if (product == null) { // Abort here - throw new NullPointerException("product is null"); + throw new NullPointerException("product is null"); //NOI18N } // Declare category @@ -1426,7 +1426,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } // Debug message - this.getLogger().debug("category=" + category); + this.getLogger().debug(MessageFormat.format("category={0}", category)); //NOI18N String title = null; try { @@ -1438,7 +1438,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } // Trace message - this.getLogger().trace("title=" + title + " - EXIT!"); + this.getLogger().trace(MessageFormat.format("title={0} - EXIT!", title)); //NOI18N // Return it return title; @@ -1459,7 +1459,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P */ private boolean isProductTitleUsed (final HttpServletRequest request) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace("request=" + request + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("request={0} - CALLED!", request)); //NOI18N // Init title String title = request.getParameter(PizzaProductDatabaseConstants.COLUMN_TITLE); @@ -1467,7 +1467,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // request must not be null and "title" must be found and non-empty if (request == null) { // Abort here - throw new NullPointerException("request is null"); + throw new NullPointerException("request is null"); //NOI18N } else if (title == null) { // title is not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaProductDatabaseConstants.COLUMN_TITLE)); //NOI18N @@ -1480,7 +1480,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P boolean isUsed = this.isProductTitleUsed(title); // Trace message - this.getLogger().trace("isUsed=" + isUsed + " - EXIT!"); + this.getLogger().trace(MessageFormat.format("isUsed={0} - EXIT!", isUsed)); //NOI18N // Return it return isUsed; @@ -1495,15 +1495,15 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P @Override public void doAdminHandleProductForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException { // Trace message - this.getLogger().trace("request=" + request + ",response=" + response + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("request={0},response={1} - CALLED!", request, response)); //NOI18N // request and response must both be set if (request == null) { // request is null - throw new NullPointerException("request is null"); + throw new NullPointerException("request is null"); //NOI18N } else if (response == null) { // response is null - throw new NullPointerException("response is null"); + throw new NullPointerException("response is null"); //NOI18N } // Try this operations @@ -1515,10 +1515,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Is it already added? if (this.isProductTitleUsed(request)) { // Debug message - this.getLogger().debug("Already used, redirecting ..."); + this.getLogger().debug("Already used, redirecting ..."); //NOI18N // Already added, so redirect here, else a ServletException will be thrown - response.sendRedirect(request.getContextPath() + "/admin/product.jsp?already=1"); + response.sendRedirect(String.format("%s/admin/product.jsp?already=1", request.getContextPath())); //NOI18N } else { // Add new product this.doAdminAddProduct(request); @@ -1539,7 +1539,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } /** @@ -1551,15 +1551,15 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P @Override public void doAdminHandleCategoryForms (final HttpServletRequest request, final HttpServletResponse response) throws ServletException { // Trace message - this.getLogger().trace("request=" + request + ",response=" + response + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("request={0},response={1} - CALLED!", request, response)); //NOI18N // request and response must both be set if (request == null) { // request is null - throw new NullPointerException("request is null"); + throw new NullPointerException("request is null"); //NOI18N } else if (response == null) { // response is null - throw new NullPointerException("response is null"); + throw new NullPointerException("response is null"); //NOI18N } // Try this operations @@ -1571,10 +1571,10 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Is the category title already used? if (this.isCategoryTitleUsed(request)) { // Debug message - this.getLogger().debug("Already used, redirecting ..."); + this.getLogger().debug("Already used, redirecting ..."); //NOI18N // Already added, so redirect here, else a ServletException will be thrown - response.sendRedirect(request.getContextPath() + "/admin/category.jsp?already=1"); + response.sendRedirect(String.format("%s/admin/category.jsp?already=1", request.getContextPath())); //NOI18N } else { // Add new category this.doAdminAddCategory(request); @@ -1595,7 +1595,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P } // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } /** @@ -1613,7 +1613,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P */ private boolean isCategoryTitleUsed (final HttpServletRequest request) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace("request=" + request + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("request={0} - CALLED!", request)); //NOI18N // Init title String title = request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE); @@ -1621,7 +1621,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // request must not be null and "title" must be found and non-empty if (request == null) { // Abort here - throw new NullPointerException("request is null"); + throw new NullPointerException("request is null"); //NOI18N } else if (title == null) { // title is not set throw new IllegalArgumentException(MessageFormat.format("{0} is not set.", PizzaCategoryDatabaseConstants.COLUMN_TITLE)); //NOI18N @@ -1634,7 +1634,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P boolean isUsed = this.isCategoryTitleUsed(title); // Trace message - this.getLogger().trace("isUsed=" + isUsed + " - EXIT!"); + this.getLogger().trace(MessageFormat.format("isUsed={0} - EXIT!", isUsed)); //NOI18N // Return it return isUsed; diff --git a/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java b/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java index 8f40185a..89c1db75 100644 --- a/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java +++ b/src/java/org/mxchange/pizzaapplication/category/BaseCategory.java @@ -71,15 +71,15 @@ public class BaseCategory extends BaseFrameworkSystem implements Category { @Override public int compareTo (final Category category) { // Trace message - this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); + this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N // category should not be null if (category == null) { - throw new NullPointerException("category is null"); + throw new NullPointerException("category is null"); //NOI18N } // Debug message - this.getLogger().debug(MessageFormat.format("this.id={0},category.id={1}", this.getId(), category.getId())); + this.getLogger().debug(MessageFormat.format("this.id={0},category.id={1}", this.getId(), category.getId())); //NOI18N // Is the id the same? if (Objects.equals(this.getId(), category.getId())) { @@ -105,7 +105,7 @@ public class BaseCategory extends BaseFrameworkSystem implements Category { byte[] t = this.getTitle().getBytes(); // Decode it - return new String(t, "UTF-8"); + return new String(t, "UTF-8"); //NOI18N } /** @@ -163,29 +163,29 @@ public class BaseCategory extends BaseFrameworkSystem implements Category { } @Override - public void setValueFromColumn (final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { // Trace message - this.getLogger().trace(MessageFormat.format("columnName={0},value={1} - CALLED!", columnName, value)); + this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); //NOI18N // Call super method - this.setValueInStoreableFromColumn(this, "BaseCategory", columnName, value); + Object value = this.getValueInStoreableFromColumn(this, "BaseCategory", columnName); //NOI18N // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N + + // Return value + return value; } @Override - public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + public void setValueFromColumn (final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); - + this.getLogger().trace(MessageFormat.format("columnName={0},value={1} - CALLED!", columnName, value)); //NOI18N + // Call super method - Object value = this.getValueInStoreableFromColumn(this, "BaseCategory", columnName); - + this.setValueInStoreableFromColumn(this, "BaseCategory", columnName, value); //NOI18N + // Trace message - this.getLogger().trace("value=" + value + " - EXIT!"); - - // Return value - return value; + this.getLogger().trace("EXIT!"); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java index 7ccc897f..cab19857 100644 --- a/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java +++ b/src/java/org/mxchange/pizzaapplication/database/category/PizzaCategoryDatabaseConstants.java @@ -25,17 +25,17 @@ public final class PizzaCategoryDatabaseConstants { /** * Column name for "id" */ - public static final String COLUMN_ID = "id"; + public static final String COLUMN_ID = "id"; //NOI18N /** * Column name for "parent" */ - public static final String COLUMN_PARENT = "parent"; + public static final String COLUMN_PARENT = "parent"; //NOI18N /** * Column name for "title" */ - public static final String COLUMN_TITLE = "title"; + public static final String COLUMN_TITLE = "title"; //NOI18N /** * No instance from this class diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java index 12e16b1d..7824c3c9 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java @@ -259,7 +259,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen @Override public Storeable toStoreable (final Map map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace("map=" + map + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("map={0} - CALLED!", map)); // Is map null? if (map == null) { @@ -271,7 +271,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen } // Debug message - this.getLogger().debug("Has to handle " + map.size() + " entries"); + this.getLogger().debug(MessageFormat.format("Has to handle {0} entries", map.size())); // Get iterator on all entries Iterator> iterator = map.entrySet().iterator(); @@ -285,14 +285,14 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen Map.Entry entry = iterator.next(); // Debug message - this.getLogger().debug("entry:" + entry.getKey() + "=" + entry.getValue()); + this.getLogger().debug(MessageFormat.format("entry:{0}={1}", entry.getKey(), entry.getValue())); // Try to set value instance.setValueFromColumn(entry.getKey(), entry.getValue()); } // Trace message - this.getLogger().trace("instance=" + instance + " - EXIT!"); + this.getLogger().trace(MessageFormat.format("instance={0} - EXIT!", instance)); // Return it return instance; @@ -307,7 +307,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen @Override public Category getCategory (final Product product) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace("product=" + product + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); // product must not be null if (product == null) { @@ -319,10 +319,10 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen Long id = product.getCategory(); // Debug message - this.getLogger().debug("id=" + id); + this.getLogger().debug(MessageFormat.format("id={0}", id)); // It should be >0 here - assert(id > 0) : "id=" + id + " must be larger zero"; + assert(id > 0) : MessageFormat.format("id={0} must be larger zero", id); // Then construct a search instance SearchableCriteria criteria = new SearchCriteria(); @@ -348,7 +348,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen Storeable storeable = result.next(); // Debug message - this.getLogger().debug("storeable=" + storeable); + this.getLogger().debug(MessageFormat.format("storeable={0}", storeable)); // Is it instance of Category? if (storeable instanceof Category) { @@ -358,7 +358,7 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen } // Trace message - this.getLogger().trace("category=" + category + " - EXIT!"); + this.getLogger().trace(MessageFormat.format("category={0} - EXIT!", category)); // Return it return category; diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java index 91d5a986..452c0d52 100644 --- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java +++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java @@ -87,20 +87,20 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement @Override public Object emptyStringToNull (final String key, final Object value) { // Trace message - this.getLogger().trace(MessageFormat.format("key={0},value={1} - CALLED!", key, value)); + this.getLogger().trace(MessageFormat.format("key={0},value={1} - CALLED!", key, value)); //NOI18N // Copy value Object v = value; // Is the value empty? - if ((value instanceof String) && ("".equals(value))) { + if ((value instanceof String) && ("".equals(value))) { //NOI18N // This value may need to be changed switch (key) { } } // Trace message - this.getLogger().trace(MessageFormat.format("v={0} - EXIT!", v)); + this.getLogger().trace(MessageFormat.format("v={0} - EXIT!", v)); //NOI18N // Return it return v; @@ -177,7 +177,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement @Override public Result getResultFromSet (final ResultSet resultSet) throws SQLException { // Trace message - this.getLogger().trace(MessageFormat.format("resultSet={0} - CALLED!", resultSet)); + this.getLogger().trace(MessageFormat.format("resultSet={0} - CALLED!", resultSet)); //NOI18N // Init result instance Result result = new DatabaseResult(); @@ -195,20 +195,20 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement Boolean available = resultSet.getBoolean(PizzaProductDatabaseConstants.COLUMN_AVAILABLE); // Debug message - this.getLogger().debug(MessageFormat.format("id={0},title={1},category={2},available={3}", id, title, category, available)); + this.getLogger().debug(MessageFormat.format("id={0},title={1},category={2},available={3}", id, title, category, available)); //NOI18N // Instance new object Product product = new PizzaProduct(id, title, price, category, available); // Debug log - this.getLogger().debug(MessageFormat.format("product={0}", product)); + this.getLogger().debug(MessageFormat.format("product={0}", product)); //NOI18N // Add it to result result.add(product); } // Trace message - this.getLogger().trace(MessageFormat.format("result({0})={1} - EXIT!", result.size(), result)); + this.getLogger().trace(MessageFormat.format("result({0})={1} - EXIT!", result.size(), result)); //NOI18N // Return result return result; @@ -226,7 +226,7 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement @Override public boolean isProductTitleUsed (String title) throws IOException, SQLException, BadTokenException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace(MessageFormat.format("title={0} - CALLED!", title)); + this.getLogger().trace(MessageFormat.format("title={0} - CALLED!", title)); //NOI18N // Get search criteria SearchableCriteria criteria = new SearchCriteria(); @@ -241,13 +241,13 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement Result result = this.getBackend().doSelectByCriteria(criteria); // Debug log - this.getLogger().debug(MessageFormat.format("result({0}={1}", result, result.size())); + this.getLogger().debug(MessageFormat.format("result({0}={1}", result, result.size())); //NOI18N // Now check size of the result boolean isFound = (result.size() == 1); // Trace message - this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound)); + this.getLogger().trace(MessageFormat.format("isFound={0} - EXIT!", isFound)); //NOI18N // Return it return isFound; @@ -264,21 +264,21 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement @Override public void addProduct (final String title, final Float price, final Long category, final Boolean available) throws SQLException, IOException { // Trace message - this.getLogger().trace(MessageFormat.format("title={0},price={1},category={2} - CALLED!", title, price, category)); + this.getLogger().trace(MessageFormat.format("title={0},price={1},category={2} - CALLED!", title, price, category)); //NOI18N // Title should not be null if (title == null) { // Abort here - throw new NullPointerException("title is null"); + throw new NullPointerException("title is null"); //NOI18N } else if (price == null) { // Abort here - throw new NullPointerException("price is null"); + throw new NullPointerException("price is null"); //NOI18N } else if (category == null) { // Abort here - throw new NullPointerException("category is null"); + throw new NullPointerException("category is null"); //NOI18N } else if (available == null) { // Abort here - throw new NullPointerException("available is null"); + throw new NullPointerException("available is null"); //NOI18N } // Clear dataset from previous usage @@ -294,10 +294,10 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement Result result = this.doInsertDataSet(); // Debug message - this.getLogger().debug(MessageFormat.format("result={0}", result)); + this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } /** @@ -311,19 +311,19 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement @Override public Storeable toStoreable (final Map map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace("map=" + map + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("map={0} - CALLED!", map)); //NOI18N // Is map null? if (map == null) { // Is null - throw new NullPointerException("map is null"); + throw new NullPointerException("map is null"); //NOI18N } else if (map.isEmpty()) { // Map is empty - throw new IllegalArgumentException("map is empty."); + throw new IllegalArgumentException("map is empty."); //NOI18N } // Debug message - this.getLogger().debug("Has to handle " + map.size() + " entries"); + this.getLogger().debug(MessageFormat.format("Has to handle {0} entries", map.size())); //NOI18N // Get iterator on all entries Iterator> iterator = map.entrySet().iterator(); @@ -337,14 +337,14 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement Map.Entry entry = iterator.next(); // Debug message - this.getLogger().debug("entry:" + entry.getKey() + "=" + entry.getValue()); + this.getLogger().debug(MessageFormat.format("entry:{0}={1}", entry.getKey(), entry.getValue())); //NOI18N // Try to set value instance.setValueFromColumn(entry.getKey(), entry.getValue()); } // Trace message - this.getLogger().trace("instance=" + instance + " - EXIT!"); + this.getLogger().trace(MessageFormat.format("instance={0} - EXIT!", instance)); //NOI18N // Return it return instance; diff --git a/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java b/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java index 4d698b11..97848c1d 100644 --- a/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java +++ b/src/java/org/mxchange/pizzaapplication/database/product/PizzaProductDatabaseConstants.java @@ -25,27 +25,27 @@ public final class PizzaProductDatabaseConstants { /** * Column name for "available" */ - public static final String COLUMN_AVAILABLE = "available"; + public static final String COLUMN_AVAILABLE = "available"; //NOI18N /** * Column name for "category" */ - public static final String COLUMN_CATEGORY = "category"; + public static final String COLUMN_CATEGORY = "category"; //NOI18N /** * Column name for "id" */ - public static final String COLUMN_ID = "id"; + public static final String COLUMN_ID = "id"; //NOI18N /** * Column name for "price" */ - public static final String COLUMN_PRICE = "price"; + public static final String COLUMN_PRICE = "price"; //NOI18N /** * Column name for "title" */ - public static final String COLUMN_TITLE = "title"; + public static final String COLUMN_TITLE = "title"; //NOI18N /** * No instance from this class diff --git a/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java b/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java index 7d695927..08d4ceaa 100644 --- a/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java +++ b/src/java/org/mxchange/pizzaapplication/exceptions/CategoryTitleAlreadyUsedException.java @@ -34,7 +34,7 @@ public class CategoryTitleAlreadyUsedException extends Exception { */ public CategoryTitleAlreadyUsedException (final HttpServletRequest request) { // Call super constructor - super(MessageFormat.format("Title {0} is already used.", request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE))); + super(MessageFormat.format("Title {0} is already used.", request.getParameter(PizzaCategoryDatabaseConstants.COLUMN_TITLE))); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java b/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java index e6509248..568ba391 100644 --- a/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java +++ b/src/java/org/mxchange/pizzaapplication/exceptions/ProductTitleAlreadyUsedException.java @@ -34,7 +34,7 @@ public class ProductTitleAlreadyUsedException extends Exception { */ public ProductTitleAlreadyUsedException (final HttpServletRequest request) { // Call super constructor - super(MessageFormat.format("Title {0} is already used.", request.getParameter(PizzaProductDatabaseConstants.COLUMN_TITLE))); + super(MessageFormat.format("Title {0} is already used.", request.getParameter(PizzaProductDatabaseConstants.COLUMN_TITLE))); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/filter/http/BaseServletFilter.java b/src/java/org/mxchange/pizzaapplication/filter/http/BaseServletFilter.java index 0e40f85f..ba8f30b2 100644 --- a/src/java/org/mxchange/pizzaapplication/filter/http/BaseServletFilter.java +++ b/src/java/org/mxchange/pizzaapplication/filter/http/BaseServletFilter.java @@ -30,22 +30,6 @@ public class BaseServletFilter extends BaseFrameworkSystem { */ private FilterConfig config; - /** - * Configuration instance - * @return the config - */ - protected FilterConfig getConfig () { - return this.config; - } - - /** - * Configuration instance - * @param config the config to set - */ - protected void setConfig (final FilterConfig config) { - this.config = config; - } - /** * Destroys this filter */ @@ -64,4 +48,20 @@ public class BaseServletFilter extends BaseFrameworkSystem { // Set config instance this.setConfig(filterConfig); } + + /** + * Configuration instance + * @return the config + */ + protected FilterConfig getConfig () { + return this.config; + } + + /** + * Configuration instance + * @param config the config to set + */ + protected void setConfig (final FilterConfig config) { + this.config = config; + } } diff --git a/src/java/org/mxchange/pizzaapplication/filter/http/utf8/Utf8HttpFilter.java b/src/java/org/mxchange/pizzaapplication/filter/http/utf8/Utf8HttpFilter.java index 51585e3a..9bdc862c 100644 --- a/src/java/org/mxchange/pizzaapplication/filter/http/utf8/Utf8HttpFilter.java +++ b/src/java/org/mxchange/pizzaapplication/filter/http/utf8/Utf8HttpFilter.java @@ -45,7 +45,7 @@ public class Utf8HttpFilter extends BaseServletFilter implements Filter { chain.doFilter(request, response); // Set response/request both to UTF-8 - request.setCharacterEncoding("UTF-8"); - response.setCharacterEncoding("UTF-8"); + request.setCharacterEncoding("UTF-8"); //NOI18N + response.setCharacterEncoding("UTF-8"); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java b/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java index f3dbf3c4..744efd9a 100644 --- a/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java +++ b/src/java/org/mxchange/pizzaapplication/product/BaseProduct.java @@ -40,6 +40,38 @@ public class BaseProduct extends BaseFrameworkSystem implements Product { */ private String title; + /** + * Compares two categories with each other + * + * @param product Product comparator + * @return Comparison value + */ + @Override + public int compareTo (final Product product) { + // Trace message + this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N + + // category should not be null + if (product == null) { + throw new NullPointerException("product is null"); //NOI18N + } + + // Debug message + this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getId(), product.getId())); //NOI18N + + // Is the id the same? + if (Objects.equals(this.getId(), product.getId())) { + // Same id, means same category + return 0; + } else if (this.getId() > product.getId()) { + // This id is larger than compared to + return 1; + } + + // The other id is larger + return -1; + } + /** * Getter for product availability * @@ -134,48 +166,16 @@ public class BaseProduct extends BaseFrameworkSystem implements Product { this.title = title; } - /** - * Compares two categories with each other - * - * @param product Product comparator - * @return Comparison value - */ - @Override - public int compareTo (final Product product) { - // Trace message - this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); - - // category should not be null - if (product == null) { - throw new NullPointerException("product is null"); - } - - // Debug message - this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getId(), product.getId())); - - // Is the id the same? - if (Objects.equals(this.getId(), product.getId())) { - // Same id, means same category - return 0; - } else if (this.getId() > product.getId()) { - // This id is larger than compared to - return 1; - } - - // The other id is larger - return -1; - } - @Override public Object getValueFromColumn (final String columnName) throws IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { // Trace message - this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); + this.getLogger().trace(MessageFormat.format("columnName={0} - CALLED!", columnName)); //NOI18N // Call super method - Object value = this.getValueInStoreableFromColumn(this, "BaseProduct", columnName); + Object value = this.getValueInStoreableFromColumn(this, "BaseProduct", columnName); //NOI18N // Trace message - this.getLogger().trace("value=" + value + " - EXIT!"); + this.getLogger().trace(MessageFormat.format("value={0} - EXIT!", value)); //NOI18N // Return value return value; @@ -184,12 +184,12 @@ public class BaseProduct extends BaseFrameworkSystem implements Product { @Override public void setValueFromColumn (final String columnName, final Object value) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // Trace message - this.getLogger().trace(MessageFormat.format("columnName={0},value={1} - CALLED!", columnName, value)); + this.getLogger().trace(MessageFormat.format("columnName={0},value={1} - CALLED!", columnName, value)); //NOI18N // Call super method - this.setValueInStoreableFromColumn(this, "BaseProduct", columnName, value); + this.setValueInStoreableFromColumn(this, "BaseProduct", columnName, value); //NOI18N // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java b/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java index 7070029d..ebc40b6e 100644 --- a/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java +++ b/src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java @@ -16,6 +16,7 @@ */ package org.mxchange.pizzaapplication.product.pizza; +import java.text.MessageFormat; import org.mxchange.pizzaapplication.product.BaseProduct; import org.mxchange.pizzaapplication.product.Product; @@ -42,7 +43,7 @@ public class PizzaProduct extends BaseProduct implements Product { */ public PizzaProduct (final Long id, final String title, final Float price, final Long category, final Boolean available) { // Trace message - this.getLogger().trace("id=" + id + ",title=" + title + ",price=" + price + ",category=" + category + ",available=" + available + " - CALLED!"); + this.getLogger().trace(MessageFormat.format("id={0},title={1},price={2},category={3},available={4} - CALLED!", id, title, price, category, available)); //NOI18N // Set all here this.setId(id); -- 2.39.5