// Path: AndroidDataBinding/DataBindingLibrary/src/main/java/com/furkanbayraktar/databinding/exception/UnsupportedSyntaxError.java
// public class UnsupportedSyntaxError extends RuntimeException{
// 
//     public UnsupportedSyntaxError(){
//         super("Wrong syntax detected in the tag.");
//     }
// 
//     public UnsupportedSyntaxError(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public UnsupportedSyntaxError(Throwable throwable) {
//         super("Wrong syntax detected in the tag.", throwable);
//     }
// 
//     public UnsupportedSyntaxError(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// }
// 
// Path: AndroidDataBinding/DataBindingLibrary/src/main/java/com/furkanbayraktar/databinding/logging/Logger.java
// public class Logger {
// 
//     public static void info(String message){
//         if(ViewBinder.getInstance().isLoggingEnabled()){
//             Log.i(ViewBinder.TAG, message);
//         }
//     }
// 
//     public static void error(String message, Throwable e){
//         Log.e(ViewBinder.TAG, message, e);
//     }
// 
//     public static void warn(String message, Throwable e){
//         if(ViewBinder.getInstance().isLoggingEnabled()) {
//             Log.w(ViewBinder.TAG, message, e);
//         }
//     }
// }


import com.furkanbayraktar.databinding.exception.UnsupportedSyntaxError;
import com.furkanbayraktar.databinding.logging.Logger;
import java.util.HashMap;
package com.furkanbayraktar.databinding.common.parser;



/**
 * Created by Furkan Bayraktar.
 * Created at 8/15/14.
 *
 */
public class Parser {

    private static Parser instance;

    private Parser(){
        Logger.info("Parser object created.");
    }

    public static Parser getInstance(){
        if(instance == null){
            instance = new Parser();
        }
        return instance;
    }

    public HashMap<String, String> parse(String tag){

        try {
            Logger.info("Parsing tag...");

            HashMap<String, String> result = new HashMap<String, String>();

            Logger.info("Looking for assignable values...");

            int start = tag.indexOf("#ASSIGN");

            if (start != -1) {
                int start2 = tag.indexOf("{", start) + 1;
                int end = tag.indexOf("}", start2);

                if (end == -1) {
                    UnsupportedSyntaxError ex = new UnsupportedSyntaxError();
                    Logger.error("Unsupported syntax.", ex);
                }

                result.put("assign", tag.substring(start2, end));

                Logger.info("Assignable values found: " + result.get("assign"));
            }

            Logger.info("Looking for visibility values...");

// Path: AndroidDataBinding/DataBindingLibrary/src/main/java/com/furkanbayraktar/databinding/exception/UnsupportedSyntaxError.java
// public class UnsupportedSyntaxError extends RuntimeException{
// 
//     public UnsupportedSyntaxError(){
//         super("Wrong syntax detected in the tag.");
//     }
// 
//     public UnsupportedSyntaxError(String detailMessage) {
//         super(detailMessage);
//     }
// 
//     public UnsupportedSyntaxError(Throwable throwable) {
//         super("Wrong syntax detected in the tag.", throwable);
//     }
// 
//     public UnsupportedSyntaxError(String detailMessage, Throwable throwable) {
//         super(detailMessage, throwable);
//     }
// }
// 
// Path: AndroidDataBinding/DataBindingLibrary/src/main/java/com/furkanbayraktar/databinding/logging/Logger.java
// public class Logger {
// 
//     public static void info(String message){
//         if(ViewBinder.getInstance().isLoggingEnabled()){
//             Log.i(ViewBinder.TAG, message);
//         }
//     }
// 
//     public static void error(String message, Throwable e){
//         Log.e(ViewBinder.TAG, message, e);
//     }
// 
//     public static void warn(String message, Throwable e){
//         if(ViewBinder.getInstance().isLoggingEnabled()) {
//             Log.w(ViewBinder.TAG, message, e);
//         }
//     }
// }


// Path: AndroidDataBinding/DataBindingLibrary/src/main/java/com/furkanbayraktar/databinding/common/parser/Parser.java
import com.furkanbayraktar.databinding.exception.UnsupportedSyntaxError;
import com.furkanbayraktar.databinding.logging.Logger;
import java.util.HashMap;

package com.furkanbayraktar.databinding.common.parser;



/**
 * Created by Furkan Bayraktar.
 * Created at 8/15/14.
 *
 */
public class Parser {

    private static Parser instance;

    private Parser(){
        Logger.info("Parser object created.");
    }

    public static Parser getInstance(){
        if(instance == null){
            instance = new Parser();
        }
        return instance;
    }

    public HashMap<String, String> parse(String tag){

        try {
            Logger.info("Parsing tag...");

            HashMap<String, String> result = new HashMap<String, String>();

            Logger.info("Looking for assignable values...");

            int start = tag.indexOf("#ASSIGN");

            if (start != -1) {
                int start2 = tag.indexOf("{", start) + 1;
                int end = tag.indexOf("}", start2);

                if (end == -1) {
                    UnsupportedSyntaxError ex = new UnsupportedSyntaxError();
                    Logger.error("Unsupported syntax.", ex);
                }

                result.put("assign", tag.substring(start2, end));

                Logger.info("Assignable values found: " + result.get("assign"));
            }

            Logger.info("Looking for visibility values...");

            start = tag.indexOf("#VISIBLE");