Java 类weka.core.logging.Logger 实例源码

项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
/**
 * Makes a copy of an object using serialization.
 * 
 * @param source the object to copy
 * @return a copy of the source object
 */
protected Object copyObject(Object source) {

  Object result = null;
  try {
    result = GenericObjectEditor.makeCopy(source);
    setCancelButton(true);

  } catch (Exception ex) {
    setCancelButton(false);
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "GenericObjectEditor: Problem making backup object");
    Logger.log(weka.core.logging.Logger.Level.WARNING, ex);
  }
  return result;
}
项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
public static void registerEditor(String name, String value) {
  Class<?> baseCls;
  Class<?> cls;

  try {
    // array class?
    if (name.endsWith("[]")) {
      baseCls = Class.forName(name.substring(0, name.indexOf("[]")));
      cls = Array.newInstance(baseCls, 1).getClass();
    } else {
      cls = Class.forName(name);
    }
    // register
    PropertyEditorManager.registerEditor(cls, Class.forName(value));
  } catch (Exception e) {
    Logger.log(weka.core.logging.Logger.Level.WARNING, "Problem registering "
      + name + "/" + value + ": " + e);
  }
}
项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
/**
 * Sets the current Object. If the Object is in the Object chooser, this
 * becomes the selected item (and added to the chooser if necessary).
 * 
 * @param o an object that must be a Object.
 */
@Override
public void setValue(Object o) {

  if (m_ClassType == null) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "No ClassType set up for GenericObjectEditor!!");
    return;
  }
  if (!m_ClassType.isAssignableFrom(o.getClass())) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "setValue object not of correct type!");
    return;
  }

  setObject(o);

  if (m_EditorComponent != null) {
    m_EditorComponent.repaint();
  }

  updateObjectNames();
}
项目:umple    文件:GenericObjectEditor.java   
/**
 * Makes a copy of an object using serialization.
 * 
 * @param source the object to copy
 * @return a copy of the source object
 */
protected Object copyObject(Object source) {

  Object result = null;
  try {
    result = GenericObjectEditor.makeCopy(source);
    setCancelButton(true);

  } catch (Exception ex) {
    setCancelButton(false);
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "GenericObjectEditor: Problem making backup object");
    Logger.log(weka.core.logging.Logger.Level.WARNING, ex);
  }
  return result;
}
项目:umple    文件:GenericObjectEditor.java   
public static void registerEditor(String name, String value) {
  Class<?> baseCls;
  Class<?> cls;

  try {
    // array class?
    if (name.endsWith("[]")) {
      baseCls = Class.forName(name.substring(0, name.indexOf("[]")));
      cls = Array.newInstance(baseCls, 1).getClass();
    } else {
      cls = Class.forName(name);
    }
    // register
    PropertyEditorManager.registerEditor(cls, Class.forName(value));
  } catch (Exception e) {
    Logger.log(weka.core.logging.Logger.Level.WARNING, "Problem registering "
      + name + "/" + value + ": " + e);
  }
}
项目:umple    文件:GenericObjectEditor.java   
/**
 * Sets the current Object. If the Object is in the Object chooser, this
 * becomes the selected item (and added to the chooser if necessary).
 * 
 * @param o an object that must be a Object.
 */
@Override
public void setValue(Object o) {

  if (m_ClassType == null) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "No ClassType set up for GenericObjectEditor!!");
    return;
  }
  if (!m_ClassType.isAssignableFrom(o.getClass())) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "setValue object not of correct type!");
    return;
  }

  setObject(o);

  if (m_EditorComponent != null) {
    m_EditorComponent.repaint();
  }

  updateObjectNames();
}
项目:meka    文件:GenericObjectEditor.java   
/**
  * Called when the class of object being edited changes.
  *
  * @return the hashtable containing the HierarchyPropertyParsers for the root
  *         elements
  */
 protected Hashtable<String, HierarchyPropertyParser> getClassesFromProperties() {
   String className = m_ClassType.getName();
   if (className.startsWith("meka.")) {
     Hashtable<String, HierarchyPropertyParser> hpps = new Hashtable<String, HierarchyPropertyParser>();
     Hashtable<String,String> typeOptions = sortClassesByRoot(EDITOR_PROPERTIES.getProperty(className));
     try {
Enumeration<String> enm = typeOptions.keys();
while (enm.hasMoreElements()) {
  String root = enm.nextElement();
  String typeOption = typeOptions.get(root);
  HierarchyPropertyParser hpp = new HierarchyPropertyParser();
  hpp.build(typeOption, ", ");
  hpps.put(root, hpp);
}
     } catch (Exception ex) {
Logger.log(weka.core.logging.Logger.Level.WARNING, "Invalid property: "
    + typeOptions);
     }
     if (DEBUG)
System.out.println("Meka classes: " + hpps);
     return hpps;
   }
   return super.getClassesFromProperties();
 }
项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
/**
 * registers all the editors in Weka.
 */
public static void registerEditors() {
  Properties props;
  Enumeration<?> enm;
  String name;
  String value;
  if (m_EditorsRegistered) {
    return;
  }

  Logger.log(weka.core.logging.Logger.Level.INFO,
    "---Registering Weka Editors---");
  m_EditorsRegistered = true;

  // load properties
  try {
    props = Utils.readProperties(GUIEDITORS_PROPERTY_FILE);
  } catch (Exception e) {
    props = new Properties();
    e.printStackTrace();
  }

  // show the tool tip?
  m_ShowGlobalInfoToolTip = props.getProperty(
    "ShowGlobalInfoToolTip", "true").equals("true");

  enm = props.propertyNames();
  while (enm.hasMoreElements()) {
    name = enm.nextElement().toString();
    value = props.getProperty(name, "");

    registerEditor(name, value);
  }
}
项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
/**
 * Sets the current object to be the default, taken as the first item in the
 * chooser.
 */
public void setDefaultValue() {

  if (m_ClassType == null) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "No ClassType set up for GenericObjectEditor!!");
    return;
  }

  Hashtable<String, HierarchyPropertyParser> hpps = getClassesFromProperties();
  HierarchyPropertyParser hpp = null;
  Enumeration<HierarchyPropertyParser> enm = hpps.elements();

  try {
    while (enm.hasMoreElements()) {
      hpp = enm.nextElement();
      if (hpp.depth() > 0) {
        hpp.goToRoot();
        while (!hpp.isLeafReached()) {
          hpp.goToChild(0);
        }

        String defaultValue = hpp.fullValue();
        setValue(Class.forName(defaultValue).newInstance());
      }
    }
  } catch (Exception ex) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "Problem loading the first class: " + hpp.fullValue());
    ex.printStackTrace();
  }
}
项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
/**
 * Called when the user selects an class type to change to.
 * 
 * @param className the name of the class that was selected
 */
protected void classSelected(String className) {

  try {
    if ((m_Object != null) && m_Object.getClass().getName().equals(className)) {
      return;
    }

    setValue(Class.forName(className).newInstance());
    // m_ObjectPropertyPanel.showPropertyDialog();
    if (m_EditorComponent != null) {
      m_EditorComponent.updateChildPropertySheet();
    }
  } catch (Exception ex) {
    JOptionPane.showMessageDialog(null, "Could not create an example of\n"
      + className + "\n" + "from the current classpath", "Class load failed",
      JOptionPane.ERROR_MESSAGE);
    ex.printStackTrace();
    try {
      if (m_Backup != null) {
        setValue(m_Backup);
      } else {
        setDefaultValue();
      }
    } catch (Exception e) {
      Logger.log(weka.core.logging.Logger.Level.WARNING, ex.getMessage());
      ex.printStackTrace();
    }
  }
}
项目:umple    文件:GenericObjectEditor.java   
/**
 * registers all the editors in Weka.
 */
public static void registerEditors() {
  Properties props;
  Enumeration<?> enm;
  String name;
  String value;
  if (m_EditorsRegistered) {
    return;
  }

  Logger.log(weka.core.logging.Logger.Level.INFO,
    "---Registering Weka Editors---");
  m_EditorsRegistered = true;

  // load properties
  try {
    props = Utils.readProperties(GUIEDITORS_PROPERTY_FILE);
  } catch (Exception e) {
    props = new Properties();
    e.printStackTrace();
  }

  enm = props.propertyNames();
  while (enm.hasMoreElements()) {
    name = enm.nextElement().toString();
    value = props.getProperty(name, "");

    registerEditor(name, value);
  }
}
项目:umple    文件:GenericObjectEditor.java   
/**
 * Sets the current object to be the default, taken as the first item in the
 * chooser.
 */
public void setDefaultValue() {

  if (m_ClassType == null) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "No ClassType set up for GenericObjectEditor!!");
    return;
  }

  Hashtable<String, HierarchyPropertyParser> hpps = getClassesFromProperties();
  HierarchyPropertyParser hpp = null;
  Enumeration<HierarchyPropertyParser> enm = hpps.elements();

  try {
    while (enm.hasMoreElements()) {
      hpp = enm.nextElement();
      if (hpp.depth() > 0) {
        hpp.goToRoot();
        while (!hpp.isLeafReached()) {
          hpp.goToChild(0);
        }

        String defaultValue = hpp.fullValue();
        setValue(Class.forName(defaultValue).newInstance());
      }
    }
  } catch (Exception ex) {
    Logger.log(weka.core.logging.Logger.Level.WARNING,
      "Problem loading the first class: " + hpp.fullValue());
    ex.printStackTrace();
  }
}
项目:umple    文件:GenericObjectEditor.java   
/**
 * Called when the user selects an class type to change to.
 * 
 * @param className the name of the class that was selected
 */
protected void classSelected(String className) {

  try {
    if ((m_Object != null) && m_Object.getClass().getName().equals(className)) {
      return;
    }

    setValue(Class.forName(className).newInstance());
    // m_ObjectPropertyPanel.showPropertyDialog();
    if (m_EditorComponent != null) {
      m_EditorComponent.updateChildPropertySheet();
    }
  } catch (Exception ex) {
    JOptionPane.showMessageDialog(null, "Could not create an example of\n"
      + className + "\n" + "from the current classpath", "Class load failed",
      JOptionPane.ERROR_MESSAGE);
    ex.printStackTrace();
    try {
      if (m_Backup != null) {
        setValue(m_Backup);
      } else {
        setDefaultValue();
      }
    } catch (Exception e) {
      Logger.log(weka.core.logging.Logger.Level.WARNING, ex.getMessage());
      ex.printStackTrace();
    }
  }
}
项目:repo.kmeanspp.silhouette_score    文件:DatabaseUtils.java   
/**
 * Initializes the database connection.
 * 
 * @param props the properties to obtain the parameters from, ignored if null
 */
public void initialize(Properties props) {
  try {
    if (props != null) {
      PROPERTIES = props;
    } else {
      PROPERTIES = Utils.readProperties(PROPERTY_FILE);
    }

    // Register the drivers in jdbc DriverManager
    String drivers = PROPERTIES.getProperty("jdbcDriver", "jdbc.idbDriver");

    if (drivers == null) {
      throw new Exception("No database drivers (JDBC) specified");
    }
    // The call to newInstance() is necessary on some platforms
    // (with some java VM implementations)
    StringTokenizer st = new StringTokenizer(drivers, ", ");
    while (st.hasMoreTokens()) {
      String driver = st.nextToken();
      boolean result;
      try {
        Class.forName(driver);
        DRIVERS.addElement(driver);
        result = true;
      } catch (Exception e) {
        result = false;
      }
      if (!result && !DRIVERS_ERRORS.contains(driver)) {
        Logger.log(Logger.Level.WARNING,
          "Trying to add database driver (JDBC): " + driver + " - "
            + "Warning, not in CLASSPATH?");
      } else if (m_Debug) {
        System.err.println("Trying to add database driver (JDBC): " + driver
          + " - " + (result ? "Success!" : "Warning, not in CLASSPATH?"));
      }
      if (!result) {
        DRIVERS_ERRORS.add(driver);
      }
    }
  } catch (Exception ex) {
    System.err.println("Problem reading properties. Fix before continuing.");
    System.err.println(ex);
  }

  m_DatabaseURL = PROPERTIES.getProperty("jdbcURL",
    "jdbc:idb=experiments.prp");
  m_stringType = PROPERTIES.getProperty("CREATE_STRING", "LONGVARCHAR");
  m_intType = PROPERTIES.getProperty("CREATE_INT", "INT");
  m_doubleType = PROPERTIES.getProperty("CREATE_DOUBLE", "DOUBLE");
  m_checkForUpperCaseNames = PROPERTIES.getProperty("checkUpperCaseNames",
    "false").equals("true");
  m_checkForLowerCaseNames = PROPERTIES.getProperty("checkLowerCaseNames",
    "false").equals("true");
  m_setAutoCommit = PROPERTIES.getProperty("setAutoCommit", "true").equals(
    "true");
  m_createIndex = PROPERTIES.getProperty("createIndex", "false").equals(
    "true");
  setKeywords(PROPERTIES.getProperty("Keywords",
    "AND,ASC,BY,DESC,FROM,GROUP,INSERT,ORDER,SELECT,UPDATE,WHERE"));
  setKeywordsMaskChar(PROPERTIES.getProperty("KeywordsMaskChar", "_"));
}
项目:repo.kmeanspp.silhouette_score    文件:GenericObjectEditor.java   
/**
 * Called when the class of object being edited changes.
 * 
 * @return the hashtable containing the HierarchyPropertyParsers for the root
 *         elements
 */
protected Hashtable<String, HierarchyPropertyParser> getClassesFromProperties() {

  Hashtable<String, HierarchyPropertyParser> hpps = new Hashtable<String, HierarchyPropertyParser>();
  String className = m_ClassType.getName();
  Set<String> cls = PluginManager.getPluginNamesOfType(className);
  if (cls == null) {
    return hpps;
  }
  List<String> toSort = new ArrayList<String>(cls);
  Collections.sort(toSort, new ClassDiscovery.StringCompare());

  StringBuilder b = new StringBuilder();
  for (String s : toSort) {
    b.append(s).append(",");
  }
  String listS = b.substring(0, b.length() - 1);
  // Hashtable typeOptions =
  // sortClassesByRoot(EDITOR_PROPERTIES.getProperty(className));
  Hashtable<String, String> typeOptions = sortClassesByRoot(listS);
  if (typeOptions == null) {
    /*
     * System.err.println("Warning: No configuration property found in\n" +
     * PROPERTY_FILE + "\n" + "for " + className);
     */
  } else {
    try {
      Enumeration<String> enm = typeOptions.keys();
      while (enm.hasMoreElements()) {
        String root = enm.nextElement();
        String typeOption = typeOptions.get(root);
        HierarchyPropertyParser hpp = new HierarchyPropertyParser();
        hpp.build(typeOption, ", ");
        hpps.put(root, hpp);
      }
    } catch (Exception ex) {
      Logger.log(weka.core.logging.Logger.Level.WARNING, "Invalid property: "
        + typeOptions);
    }
  }
  return hpps;
}
项目:umple    文件:DatabaseUtils.java   
/**
 * Initializes the database connection.
 * 
 * @param props the properties to obtain the parameters from, ignored if null
 */
public void initialize(Properties props) {
  try {
    if (props != null) {
      PROPERTIES = props;
    } else {
      PROPERTIES = Utils.readProperties(PROPERTY_FILE);
    }

    // Register the drivers in jdbc DriverManager
    String drivers = PROPERTIES.getProperty("jdbcDriver", "jdbc.idbDriver");

    if (drivers == null) {
      throw new Exception("No database drivers (JDBC) specified");
    }
    // The call to newInstance() is necessary on some platforms
    // (with some java VM implementations)
    StringTokenizer st = new StringTokenizer(drivers, ", ");
    while (st.hasMoreTokens()) {
      String driver = st.nextToken();
      boolean result;
      try {
        Class.forName(driver);
        DRIVERS.addElement(driver);
        result = true;
      } catch (Exception e) {
        result = false;
      }
      if (!result && !DRIVERS_ERRORS.contains(driver)) {
        Logger.log(Logger.Level.WARNING,
          "Trying to add database driver (JDBC): " + driver + " - "
            + "Warning, not in CLASSPATH?");
      } else if (m_Debug) {
        System.err.println("Trying to add database driver (JDBC): " + driver
          + " - " + (result ? "Success!" : "Warning, not in CLASSPATH?"));
      }
      if (!result) {
        DRIVERS_ERRORS.add(driver);
      }
    }
  } catch (Exception ex) {
    System.err.println("Problem reading properties. Fix before continuing.");
    System.err.println(ex);
  }

  m_DatabaseURL = PROPERTIES.getProperty("jdbcURL",
    "jdbc:idb=experiments.prp");
  m_stringType = PROPERTIES.getProperty("CREATE_STRING", "LONGVARCHAR");
  m_intType = PROPERTIES.getProperty("CREATE_INT", "INT");
  m_doubleType = PROPERTIES.getProperty("CREATE_DOUBLE", "DOUBLE");
  m_checkForUpperCaseNames = PROPERTIES.getProperty("checkUpperCaseNames",
    "false").equals("true");
  m_checkForLowerCaseNames = PROPERTIES.getProperty("checkLowerCaseNames",
    "false").equals("true");
  m_setAutoCommit = PROPERTIES.getProperty("setAutoCommit", "true").equals(
    "true");
  m_createIndex = PROPERTIES.getProperty("createIndex", "false").equals(
    "true");
  setKeywords(PROPERTIES.getProperty("Keywords",
    "AND,ASC,BY,DESC,FROM,GROUP,INSERT,ORDER,SELECT,UPDATE,WHERE"));
  setKeywordsMaskChar(PROPERTIES.getProperty("KeywordsMaskChar", "_"));
}
项目:umple    文件:GenericObjectEditor.java   
/**
 * Called when the class of object being edited changes.
 * 
 * @return the hashtable containing the HierarchyPropertyParsers for the root
 *         elements
 */
protected Hashtable<String, HierarchyPropertyParser> getClassesFromProperties() {

  Hashtable<String, HierarchyPropertyParser> hpps = new Hashtable<String, HierarchyPropertyParser>();
  String className = m_ClassType.getName();
  Set<String> cls = PluginManager.getPluginNamesOfType(className);
  if (cls == null) {
    return hpps;
  }
  List<String> toSort = new ArrayList<String>(cls);
  Collections.sort(toSort, new ClassDiscovery.StringCompare());

  StringBuilder b = new StringBuilder();
  for (String s : toSort) {
    b.append(s).append(",");
  }
  String listS = b.substring(0, b.length() - 1);
  // Hashtable typeOptions =
  // sortClassesByRoot(EDITOR_PROPERTIES.getProperty(className));
  Hashtable<String, String> typeOptions = sortClassesByRoot(listS);
  if (typeOptions == null) {
    /*
     * System.err.println("Warning: No configuration property found in\n" +
     * PROPERTY_FILE + "\n" + "for " + className);
     */
  } else {
    try {
      Enumeration<String> enm = typeOptions.keys();
      while (enm.hasMoreElements()) {
        String root = enm.nextElement();
        String typeOption = typeOptions.get(root);
        HierarchyPropertyParser hpp = new HierarchyPropertyParser();
        hpp.build(typeOption, ", ");
        hpps.put(root, hpp);
      }
    } catch (Exception ex) {
      Logger.log(weka.core.logging.Logger.Level.WARNING, "Invalid property: "
        + typeOptions);
    }
  }
  return hpps;
}