From: Roland Haeder Date: Tue, 6 Oct 2015 10:09:58 +0000 (+0200) Subject: Let's get rid of this class. It was maybe a good idea, but it required a lot work... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=48414c54f2c356ee08ef56848442e9e0e2349af0;p=jcoreee.git Let's get rid of this class. It was maybe a good idea, but it required a lot work only for internationalized messages ... So for now these "internal" messages are now in English language only. Signed-off-by:Roland Häder --- diff --git a/lib/jcore.jar b/lib/jcore.jar index 2c6f30e..b506a16 100644 Binary files a/lib/jcore.jar and b/lib/jcore.jar differ diff --git a/src/org/mxchange/jcoreee/BaseEeSystem.java b/src/org/mxchange/jcoreee/BaseEeSystem.java deleted file mode 100644 index 357b1b7..0000000 --- a/src/org/mxchange/jcoreee/BaseEeSystem.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2015 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcoreee; - -import java.io.Serializable; -import java.util.ResourceBundle; - -/** - * A general class for Java EE applications. You should not include this in your - * web applications as this requires that the bundle has to be placed here. - *

- * @author Roland Haeder - */ -public abstract class BaseEeSystem implements Serializable { - - /** - * Serial number - */ - private static final long serialVersionUID = 48_475_834_783_473_187L; - - /** - * Bundle instance - */ - private final ResourceBundle bundle; - - /** - * Protectd constructor - */ - protected BaseEeSystem () { - // Load resource bundle - this.bundle = ResourceBundle.getBundle("org/mxchange/localization/bundle"); - } - - /** - * Getter for bundle instance - *

- * @return Bundle instance - */ - private ResourceBundle getBundle () { - return this.bundle; - } - - /** - * Getter for message from given key - *

- * @param key Key to get message from - * @return Message - */ - protected String getMessageFromKey (final String key) { - // Is the bundle loaded? - if (this.getBundle() == null) { - // Abort here - throw new NullPointerException("bundle is null"); //NOI18N - } - - // Return message - return this.getBundle().getString(key); - } -} diff --git a/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java b/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java index a8bd8fc..fa3d625 100644 --- a/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java +++ b/src/org/mxchange/jcoreee/validator/BaseObjectValidator.java @@ -22,7 +22,6 @@ import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; -import org.mxchange.jcoreee.BaseEeSystem; /** * A general object validation class. Please implement @@ -32,7 +31,7 @@ import org.mxchange.jcoreee.BaseEeSystem; *

* @author Roland Haeder */ -public abstract class BaseObjectValidator extends BaseEeSystem implements Validator { +public abstract class BaseObjectValidator implements Validator { /** * Serial number @@ -69,7 +68,6 @@ public abstract class BaseObjectValidator extends BaseEeSystem implements Valida // Init message and key FacesMessage facesMessage = null; - String errKey = "ERROR_UNKNOWN_ID"; //NOI18N // Get client id final String clientId = component.getClientId(); @@ -89,11 +87,8 @@ public abstract class BaseObjectValidator extends BaseEeSystem implements Valida // Is it null? if (null == value) { - // Generate message - errKey = String.format("ERROR_%s_IS_NULL", field.toUpperCase()); //NOI18N - // Value it null - facesMessage = new FacesMessage(this.getMessageFromKey(errKey)); + facesMessage = new FacesMessage(MessageFormat.format("Field {0} is null.", field)); //NOI18N } // Abort here @@ -106,7 +101,7 @@ public abstract class BaseObjectValidator extends BaseEeSystem implements Valida // Valid field? if (!isValidField) { // Invalid field - facesMessage = new FacesMessage(MessageFormat.format(this.getMessageFromKey(errKey), clientId)); + facesMessage = new FacesMessage(MessageFormat.format("Valure {0} for clientId={1} is not valid/unexpected.", value, clientId)); //NOI18N } // Debug message diff --git a/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java b/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java index a7a9083..122d0a0 100644 --- a/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java +++ b/src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java @@ -62,7 +62,7 @@ public abstract class BaseBooleanValidator extends BaseObjectValidator implement // Compare value's type if (!(value instanceof Boolean)) { // Generate message - requiredMessage = this.getMessageFromKey(String.format("ERROR_%s_IS_NOT_BOOLEAN", field.toUpperCase())); + requiredMessage = MessageFormat.format("Field {0} is not Boolean.", field); //NOI18N // Value is not right type facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); //NOI18N diff --git a/src/org/mxchange/jcoreee/validator/number/BaseLongValidator.java b/src/org/mxchange/jcoreee/validator/number/BaseLongValidator.java index 8d543aa..9406d52 100644 --- a/src/org/mxchange/jcoreee/validator/number/BaseLongValidator.java +++ b/src/org/mxchange/jcoreee/validator/number/BaseLongValidator.java @@ -16,6 +16,7 @@ */ package org.mxchange.jcoreee.validator.number; +import java.text.MessageFormat; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; @@ -58,7 +59,7 @@ public abstract class BaseLongValidator extends BaseObjectValidator implements V // Compare value's type if (!(value instanceof Long)) { // Generate message - requiredMessage = this.getMessageFromKey(String.format("ERROR_%s_IS_NOT_LONG", field.toUpperCase())); + requiredMessage = MessageFormat.format("Field {0} is not Long.", field); //NOI18N // Value is not right type facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); //NOI18N @@ -71,7 +72,7 @@ public abstract class BaseLongValidator extends BaseObjectValidator implements V // Is the number below zero? if (num < 0) { // Generate message - requiredMessage = this.getMessageFromKey(String.format("ERROR_%s_IS_BELOW_ZERO", field.toUpperCase())); + requiredMessage = MessageFormat.format("Value {0} for field {1} is below zero.", num, field); //NOI18N // Abort processing here facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage); diff --git a/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java b/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java index 5fc4535..02926b2 100644 --- a/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java +++ b/src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java @@ -16,6 +16,7 @@ */ package org.mxchange.jcoreee.validator.string; +import java.text.MessageFormat; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; @@ -46,7 +47,6 @@ public abstract class BaseStringValidator extends BaseObjectValidator { // Get client id and init message + key String clientId = component.getClientId(); FacesMessage facesMessage = null; - String errKey; // So far all fine, no check if the field is fine for (final String field : requiredFields) { @@ -58,9 +58,7 @@ public abstract class BaseStringValidator extends BaseObjectValidator { // Compare value's type if (!(value instanceof String)) { // Value is empty - errKey = String.format("ERROR_%s_IS_NOT_STRING", field.toUpperCase()); //NOI18N - - facesMessage = new FacesMessage(this.getMessageFromKey(errKey)); + facesMessage = new FacesMessage(MessageFormat.format("Field {0} is not set to String.", field)); //NOI18N } // Cast to string @@ -68,10 +66,8 @@ public abstract class BaseStringValidator extends BaseObjectValidator { // Is it empty? if (str.isEmpty()) { - // Value is empty - errKey = String.format("ERROR_%s_IS_EMPTY", field.toUpperCase()); //NOI18N - - facesMessage = new FacesMessage(this.getMessageFromKey(errKey)); + // Generate message + facesMessage = new FacesMessage(MessageFormat.format("Field {0} is empty.", field)); //NOI18N } } }