]> git.mxchange.org Git - jcore-utils.git/commitdiff
Let's get rid of this class. It was maybe a good idea, but it required a lot work...
authorRoland Haeder <roland@mxchange.org>
Tue, 6 Oct 2015 10:09:58 +0000 (12:09 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 6 Oct 2015 10:09:58 +0000 (12:09 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcore.jar
src/org/mxchange/jcoreee/BaseEeSystem.java [deleted file]
src/org/mxchange/jcoreee/validator/BaseObjectValidator.java
src/org/mxchange/jcoreee/validator/bool/BaseBooleanValidator.java
src/org/mxchange/jcoreee/validator/number/BaseLongValidator.java
src/org/mxchange/jcoreee/validator/string/BaseStringValidator.java

index 2c6f30efe9f8c246eae16a87aef835bb909ba01d..b506a165e930439400060fff313b735ea2ad09f3 100644 (file)
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 (file)
index 357b1b7..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-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
-        * <p>
-        * @return Bundle instance
-        */
-       private ResourceBundle getBundle () {
-               return this.bundle;
-       }
-
-       /**
-        * Getter for message from given key
-        * <p>
-        * @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);
-       }
-}
index a8bd8fcab8cc22a622bfd47e990be4631b9be13a..fa3d625333a19deb0935349e8536f2ca71a99d3c 100644 (file)
@@ -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;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-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
index a7a9083c2fcf379e8ee8cd222b96c983f3093cea..122d0a026261e82a1f5c005ceb285e1effd4949c 100644 (file)
@@ -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
index 8d543aaebe4adc31e144a3f85c0127c14c472308..9406d523c9416da43084fd5681ac243fcdac50b2 100644 (file)
@@ -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);
index 5fc45350a93197ca3243ceb277bfc2b17fa6a264..02926b2c70d7a2c2e5a9a9d856333f8a00e9b3b7 100644 (file)
@@ -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
                                }
                        }
                }