package failchat.core;

import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MessageObjectCleaner implements MessageHandler {

    public static final Pattern pattern = Pattern.compile("\\{!\\d{1,3}\\}");
    private static volatile MessageObjectCleaner instance;


    private MessageObjectCleaner() {

    }

    public static MessageObjectCleaner getInstance() {
        MessageObjectCleaner localInstance = instance;
        if (localInstance == null) {
            synchronized (MessageObjectCleaner.class) {
                localInstance = instance;
                if (localInstance == null) {
                    instance = localInstance = new MessageObjectCleaner();
                }
            }
        }
        return localInstance;
    }

    private static final Logger logger = Logger.getLogger(MessageObjectCleaner.class.getName());

    @Override
    public void handleMessage(Message message) {
        Matcher m = pattern.matcher(message.getText());
        if (m.find()) {
            logger.fine("Message cleaned - " + message.getAuthor() + ": " + message.getText());
            message.setText(m.replaceAll(""));
        }
    }
}
@@ -54,72 +54,58 @@
 er;%0A
-import java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A
+/**%0A * %D0%97%D0%B0%D0%BC%D0%B5%D0%BD%D1%8F%D0%B5%D1%82 %D1%81%D0%B8%D0%BC%D0%B2%D0%BE%D0%BB%D1%8B %7B %D0%B8 %7D %D0%BD%D0%B0 html entity%0A * */
 %0Apub
@@ -163,35 +163,35 @@
 ndler %7B%0A
-%0A
     p
-ublic
+rivate
  static 
 final Pa
@@ -186,96 +186,106 @@
 tic 
-final Pattern pattern = Pattern.compile(%22%5C%5C%7B!%5C%5Cd%7B1,3%7D%5C%5C%7D%22);%0A    private static volatile 
+volatile MessageObjectCleaner instance;%0A    private static final Logger logger = Logger.getLogger(
 Mess
@@ -300,27 +300,34 @@
 tCleaner
- instance;%0A
+.class.getName());
 %0A%0A    pr
@@ -813,106 +813,8 @@
  %7D%0A%0A
-    private static final Logger logger = Logger.getLogger(MessageObjectCleaner.class.getName());%0A%0A
     
@@ -884,36 +884,21 @@
     
-Matcher m = pattern.matcher(
+String mes = 
 mess
@@ -902,33 +902,32 @@
 essage.getText()
-)
 ;%0A        if (m.
@@ -924,176 +924,121 @@
     
-if (m.find()) %7B%0A            logger.fine(%22Message cleaned - %22 + message.getAuthor() + %22: %22 + message.getText());%0A            message.setText(m.replaceAll(%22%22));%0A        %7D
+mes = mes.replaceAll(%22%5C%5C%7B%22, %22&#123;%22);%0A        mes = mes.replaceAll(%22%7D%22, %22&#125;%22);%0A        message.setText(mes);
 %0A   

Replace characters { and } for html entities