⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debug.java

📁 矩阵的QR分解算法
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    public double nextGaussian() {      double result = super.nextGaussian();      println("nextGaussian=" + result);      return result;    }    /**     * Returns the next pseudorandom, uniformly distributed int  value from this     * random number generator's sequence.     *      * @return		random int     */    public int nextInt() {      int result = super.nextInt();      println("nextInt=" + result);      return result;    }    /**     * Returns a pseudorandom, uniformly distributed int value between 0     * (inclusive) and the specified value (exclusive), drawn from this random     * number generator's sequence.     *      * @param n		the upper limit (exclusive)     * @return		random int     */    public int nextInt(int n) {      int result = super.nextInt(n);      println("nextInt(" + n + ")=" + result);      return result;    }    /**     * Returns the next pseudorandom, uniformly distributed long  value from this     * random number generator's sequence.     *      * @return		random long     */    public long nextLong() {      long result = super.nextLong();      println("nextLong=" + result);      return result;    }    /**     * Sets the seed of this random number generator using a single long seed.     *      * @param seed	the seed value     */    public void setSeed(long seed) {      super.setSeed(seed);      println("setSeed(" + seed + ")");    }    /**     * returns a string representation of this number generator     *      * @return		a string representation     */    public String toString() {      return this.getClass().getName() + ": " + getID();    }  }  /**   * contains debug methods   *   * @author Gabi Schmidberger (gabi at cs dot waikato dot ac dot nz)   * @version $Revision: 1.7 $   */  public static class DBO     implements Serializable {    /** for serialization */    static final long serialVersionUID = -5245628124742606784L;      /** enables/disables output of debug information */    public boolean m_verboseOn = false;    /** range of outputtyp */    public Range m_outputTypes = new Range();    /**      * Set the verbose on flag on     */    public void setVerboseOn() {      m_verboseOn = true;    }    /**      * Initialize ranges, upper limit must be set     *      * @param upper upper limit     */    public void initializeRanges(int upper) {      m_outputTypes.setUpper(upper);    }    /**     * Return true if the outputtype is set     *      * @param num value that is reserved for a specific outputtype     * @return return true if the output type is set     */    public boolean outputTypeSet(int num) {      return (m_outputTypes.isInRange(num));    }     /**     * Return true if the debug level is set     * same method as outpuTypeSet but better name     *      * @param num value that is reserved for a specific outputtype     * @return return true if the debug level is set     */    public boolean dl(int num) {      return (outputTypeSet(num));    }   /**     * Switches the outputs on that are requested from the option O     *      * @param list list of integers, all are used for an output type     */    public void setOutputTypes(String list) {      if (list.length() > 0) {        m_verboseOn = true;         m_outputTypes.setRanges(list);        m_outputTypes.setUpper(30);      }    }    /**     * Gets the current output type selection     *     * @return a string containing a comma separated list of ranges     */    public String getOutputTypes() {      return m_outputTypes.getRanges();    }    /**     * prints out text + endofline if verbose is on.     * helps to make debug output commands more visible in text     *      * @param text the text to print     */    public void dpln(String text) {      if (m_verboseOn) {        System.out.println(text);      }    }     /**     * prints out text + endofline but only if parameter debug type is set.     * helps to make debug output commands more visible in text     *     * @param debugType the type of the output     * @param text the text to print     */    public void dpln(int debugType, String text) {      if (outputTypeSet(debugType)) {        System.out.println(text);      }    }      /**     * prints out text  if verbose is on.     * helps to make debug output commands more visible in text     *      * @param text the text to print     */    public void dp(String text) {      if (m_verboseOn) {        System.out.print(text);      }    }    /**     * prints out text but only if debug level is set.     * helps to make debug output commands more visible in text     *     * @param debugType the type of the output     * @param text the text to print     */    public void dp(int debugType, String text) {     if (outputTypeSet(debugType)) {        System.out.print(text);      }    }     /**     * prints out text + endofline.     * helps to make debug output commands more visible in text     *      * @param text the text to print     */    public static void pln(String text) {      System.out.println(text);    }     /**     * prints out text.     * helps to make debug output commands more visible in text     *      * @param text the text to print     */    public static void p (String text) {      System.out.print(text);    }   }    /**   * default constructor, prints only to stdout   */  public Debug() {    this(null);  }    /**   * logs the output to the specified file (and stdout). Size is 1,000,000 bytes    * and 1 file.   *    * @param filename	the name of the log   */  public Debug(String filename) {    this(filename, 1000000, 1);  }    /**   * logs the output   *    * @param filename	the name of the log   * @param size	the size of the files in bytes   * @param numFiles	the number of files for rotating   */  public Debug(String filename, int size, int numFiles) {    super();        m_Log = newLog(filename, size, numFiles);  }    /**   * turns the string representing a level, e.g., "FINE" or "ALL" into   * the corresponding level (case-insensitive). The default is ALL.   *    * @param level	the string to return a level for   * @return		the corresponding level or the default   */  public static Level stringToLevel(String level) {    return Log.stringToLevel(level);  }    /**   * returns a new Log instance   *    * @param filename	the name of the log   * @param size	the size of the files in bytes   * @param numFiles	the number of files for rotating   * @return		the log instance   */  public static Log newLog(String filename, int size, int numFiles) {    return new Log(filename, size, numFiles);  }    /**   * prints the given message with level INFO   *    * @param message	the message to print   */  public void log(String message) {    log(INFO, message);  }    /**   * prints the given message with the specified level and an empty sourceclass   *    * @param level	the level of logging   * @param message	the message to print   */  public void log(Level level, String message) {    log(level, "", message);  }    /**   * prints the given message with the specified level   *    * @param level	the level of logging   * @param sourceclass	the class that logs the message   * @param message	the message to print   */  public void log(Level level, String sourceclass, String message) {    log(level, sourceclass, "", message);  }    /**   * prints the given message with the specified level   *    * @param level		the level of logging   * @param sourceclass		the class that logs the message   * @param sourcemethod	the method that logs the message   * @param message		the message to print   */  public void log(Level level, String sourceclass, String sourcemethod, String message) {    if (getEnabled())      m_Log.log(level, sourceclass, sourcemethod, message);  }    /**   * sets whether the logging is enabled or not   *    * @param value	if true logging will be enabled   */  public void setEnabled(boolean value) {    m_Enabled = value;  }    /**   * returns whether the logging is enabled   *    * @return		true if the logging is enabled   */  public boolean getEnabled() {    return m_Enabled;  }    /**   * returns a new instance of a clock   *    * @return		a new instance of a Clock   */  public static Clock newClock() {    return new Clock();  }    /**   * returns the instance of the Clock that is internally used   *    * @return		the clock that's being used   */  public Clock getClock() {    return m_Clock;  }    /**   * starts the clock   */  public void startClock() {    m_Clock.start();  }    /**   * stops the clock and prints the message associated with the time, but only   * if the logging is enabled.   *    * @param message	the message to print   * @see		#getEnabled()   */  public void stopClock(String message) {    log(message + ": " + m_Clock);  }    /**   * returns a default debug random object, with no particular seed and    * debugging enabled.   *    * @return		a new instance of a Random object   */  public static java.util.Random newRandom() {    return new Random(true);  }    /**   * returns a debug random object with the specified seed and debugging    * enabled.   *    * @param seed	the seed value   * @return		a new instance of a Random object   */  public static java.util.Random newRandom(int seed) {    return new Random(seed, true);  }  /**   * returns a default timestamp for the current date/time   *    * @return		a new timestamp   */  public static Timestamp newTimestamp() {    return new Timestamp();  }    /**   * returns the system temp directory   *    * @return		the temp directory   */  public static String getTempDir() {    return System.getProperty("java.io.tmpdir");  }    /**   * returns the home directory of the user   *    * @return		the user's home directory   */  public static String getHomeDir() {    return System.getProperty("user.home");  }    /**   * returns the current working directory of the user   *    * @return		the user's current working directory   */  public static String getCurrentDir() {    return System.getProperty("user.dir");  }    /**   * Writes the given object to the specified file. The string representation   * of the object is appended to the file.   *    * @param filename	the file to write to   * @param obj		the object to write to the file   * @return		true if writing was successful   */  public static boolean writeToFile(String filename, Object obj) {    return writeToFile(filename, obj, true);  }    /**   * Writes the given message to the specified file. The message is appended    * to the file.   *    * @param filename	the file to write to   * @param message	the message to write   * @return		true if writing was successful   */  public static boolean writeToFile(String filename, String message) {    return writeToFile(filename, message, true);  }    /**   * Writes the given object to the specified file. The string representation    * of the object is either appended or replaces the current content of the    * file.   *    * @param filename	the file to write to   * @param obj		the object to write to the file   * @param append	whether to append the message or not   * @return		true if writing was successful   */  public static boolean writeToFile(String filename, Object obj, boolean append) {    return writeToFile(filename, obj.toString(), append);  }    /**   * Writes the given message to the specified file. The message is either    * appended or replaces the current content of the file.   *    * @param filename	the file to write to   * @param message	the message to write   * @param append	whether to append the message or not   * @return		true if writing was successful   */  public static boolean writeToFile(String filename, String message, boolean append) {    boolean		result;    BufferedWriter	writer;        try {      writer = new BufferedWriter(new FileWriter(filename, append));      writer.write(message);      writer.newLine();      writer.flush();      writer.close();      result = true;    }    catch (Exception e) {      result = false;    }        return result;  }    /**   * writes the serialized object to the speicified file   *    * @param filename	the file to serialize the object to   * @param o		the object to serialize   * @return		true if writing was successful   */  public static boolean saveToFile(String filename, Object o) {    boolean 	result;        if (SerializationHelper.isSerializable(o.getClass())) {      try {	SerializationHelper.write(filename, o);	result = true;      }      catch (Exception e) {	result = false;      }    }    else {      result = false;    }        return result;  }    /**   * deserializes the content of the file and returns it, null if an error   * occurred.   *    * @param filename	the name of the file to deserialize   * @return		the deserialized content, null if problem occurred   */  public static Object loadFromFile(String filename) {    Object	result;        try {      result = SerializationHelper.read(filename);    }    catch (Exception e) {      result = null;    }        return result;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -