69Fermer71
mephistonLe 24/02/2011 à 18:40
Bonjour à tous,

Je viens de m'inscrire sur ce forum car la personne qui a des problèmes en JAVA c'est moi. Pour vous expliquer mon problème, je me retrouve avec un projet à rendre dans l'urgence et le JAVA n'est pas un code que je maitrise.

Pour le moment j'ai réussi à faire certaines fonctions mais il y en a certaines qui me posent encore beaucoup de problèmes. Concernant remove SQL il s'agit de recupérer une chaine de caractère en supprimant tout ce qui peut faire une injection SQL dedans.
Sinon un autre problème c'est au niveau de l'email j'ai essayé de récupérer une regex de la norme RFC 2822 mais ca ne passe pas.
package org.esgi.javaweb; import java.text.SimpleDateFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; public class StringUtility // implements IStringUtility { public static void main(String[] args) { String var1 = "yves@gmail.com"; System.out.println(isEmail(var1)); } public static boolean isEmpty(String input) { if (input == null || input.trim().equals("")) return true; else { return false; } } public static boolean isInteger(String input) { if (!isEmpty(input)) { try { Integer.parseInt(input.trim()); return true; } catch (NumberFormatException e) { return false; } } else return false; } public static boolean isNumeric(String input) { if (!isEmpty(input)) { try { Double.parseDouble(input.trim().replace(",", ".")); return true; } catch (NumberFormatException e) { return false; } } else return false; } public static boolean isEmail(String input) { if (!isEmpty(input)) { // The Official Standard: RFC 2822 return Pattern.matches("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b", input); } else return false; } public static boolean isBoolean(String input) { if (!isEmpty(input)) { return "true".equalsIgnoreCase(input) || "false".equalsIgnoreCase(input) || input.equals("1") || input.equals("1"); } else return false; } public static boolean isDate(String pattern, String input) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); if (!isEmpty(input)) { if (input.trim().length() != dateFormat.toPattern().length()) { return false; } dateFormat.setLenient(false); try { dateFormat.parse(input.trim()); } catch (Exception e) { return false; } return true; } else return false; } public static String removeSQL(String input) { } public static String removeJavascript(String input) { } public static String removeXmlTags(String input) { return input.replaceAll("<[^>]+>", ""); } public static String removeXmlTags(String tag, String input) { } public static String normalize(String input) { } }