CPD Results

The following document contains the results of PMD's CPD 4.3.

Duplications

File Line
de\smartics\exceptions\AbstractCoreException.java 109
de\smartics\exceptions\AbstractCoreRuntimeException.java 112
  protected AbstractCoreException(final String message, final Throwable cause,
      final Code code) throws NullPointerException
  {
    super(message, Helper.provideException(cause));
    this.info = new ExceptionInfo(cause, code);
  }

  // ****************************** Inner Classes *****************************

  // ********************************* Methods ********************************

  // --- init -----------------------------------------------------------------

  // --- get&set --------------------------------------------------------------

  @Override
  public final ExceptionId<?> getId()
  {
    return info.getId();
  }

  @Override
  public final Code getCode()
  {
    return info.getCode();
  }

  @Override
  public final Date getTime()
  {
    return info.getTime();
  }

  @Override
  public final Throwable getCause()
  {
    if (Helper.getThrowableHandleMode() == ThrowableHandleMode.NORMAL)
    {
      return super.getCause();
    }
    else
    {
      return info.removeableCause;
    }
  }

  // --- business -------------------------------------------------------------

  @Override
  public final void truncateCause()
  {
    Helper.truncateCause(this, this.info);
  }

  // --- object basics --------------------------------------------------------

  /**
   * Returns a class loader to provide resources from the class path.
   *
   * @return a class loader to provide resources from the class path.
   */
  protected final ClassLoader getClassLoader()
  {
    final ClassLoader loader =
        new FallbackClassLoader(Thread.currentThread()
            .getContextClassLoader(), getClass().getClassLoader()); // NOPMD
    return loader;
  }

  /**
   * Returns the string representation of the exception.
   * <p>
   * May be overridden by subclasses in an application (not a library) to change
   * the string representation. Usually an implementation of
   * {@code CodeMessageFormatter} should be set to the
   * {@link de.smartics.exceptions.ExceptionContext}.
   * </p>
   *
   * @return the string representation of the object.
   */
  @Override
  public String toString()
  {
    final CodeMessageFormatter formatter =
        ExceptionContextManager.getFormatter(getClassLoader());
    final String string = formatter.format(this);
    return string;
  }
}