From 48414c54f2c356ee08ef56848442e9e0e2349af0 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 6 Oct 2015 12:09:58 +0200 Subject: [PATCH] =?utf8?q?Let's=20get=20rid=20of=20this=20class.=20It=20wa?= =?utf8?q?s=20maybe=20a=20good=20idea,=20but=20it=20required=20a=20lot=20w?= =?utf8?q?ork=20only=20for=20internationalized=20messages=20...=20So=20for?= =?utf8?q?=20now=20these=20"internal"=20messages=20are=20now=20in=20Englis?= =?utf8?q?h=20language=20only.=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcore.jar | Bin 13647 -> 13647 bytes src/org/mxchange/jcoreee/BaseEeSystem.java | 73 ------------------ .../validator/BaseObjectValidator.java | 11 +-- .../validator/bool/BaseBooleanValidator.java | 2 +- .../validator/number/BaseLongValidator.java | 5 +- .../validator/string/BaseStringValidator.java | 12 +-- 6 files changed, 11 insertions(+), 92 deletions(-) delete mode 100644 src/org/mxchange/jcoreee/BaseEeSystem.java diff --git a/lib/jcore.jar b/lib/jcore.jar index 2c6f30efe9f8c246eae16a87aef835bb909ba01d..b506a165e930439400060fff313b735ea2ad09f3 100644 GIT binary patch delta 461 zcmX?~bv}zXz?+$ci-CcIfniFd+eBUs=E*?HVj44ucTpZpebxX`ljRuoz_dT36^Ne1 zq%wH}qaax52%{xL$P~=AU@`;Kg-lK$dh<4>lRSbzhP%k5$6FYg7#KiUd$OX6*yQ^L z5}Wt&b2EX}oe{jn2xhDlehgvsi#}%ti&RQpV+0$K_0}iw2qOan2)lrdm?O(QdA*U^ z=H=4oAet&tf zdAamCh^7kJPKbFd3jPpAn9?qYl(32~gpsV8%mz02r1n&>$mB#_3y|L@&(XC9Nld<{ zs}H6H^en)%x1JrC?$PrC)4BT6lfUR`f!T`so=`DYFuhgZ4NU*j4+7J{2H{|Otw9)= zW;2Wi(cmYT>atBB@;6M%0gYUU AA^-pY 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 } } } -- 2.39.2