/* **********************************************************************
 * source:    MyMarshallingBase
 * package:   com.me.my.xml.toys
 * author:    sisjo
 ************************************************************************/
package com.me.my.xml.toys;

import java.util.logging.Logger;
import java.util.logging.Level;
import java.io.File;

/*************
* class: MyMarshallingBase
* <p>
* This is a class to host the concrete guys
*/
public abstract class MyMarshallingBase {
  private Logger myLogger;

  protected MyMarshallingBase(Logger logger) {
    myLogger = logger;
  }

  // == polymorphics

  protected void reportException(String sEx, Throwable th) {
    myLogger.log(Level.SEVERE, sEx, th);
  }

  protected void reportError(String sError) {
    myLogger.log(Level.SEVERE, sError);
  }

  protected void reportInfo(String sInfo) {
    myLogger.log(Level.INFO, sInfo);
  }

  protected Logger getLogger() {
    return myLogger;
  }


  protected static boolean okStr(String sX, boolean nonBlank) {
    boolean ok = ((sX != null) && (sX.length() > 0));
    if (ok && nonBlank) {
      ok = (sX.trim().length() > 0);
    }
    return ok;
  }

  protected static String badStr(String sX, String bad) {
    return (okStr(sX, true) ? sX : bad);
  }

  protected static boolean okFile(File fil) {
    return ((fil != null) && fil.exists() && fil.isFile());
  }

}
