CPD Results

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

Duplications

File Line
de\smartics\exceptions\i18n\AbstractMessageException.java 200
de\smartics\exceptions\i18n\AbstractMessageRuntimeException.java 200
        messageBean.getLocalizedInfo().getLocalizedMessage(messageBean,
            keyPrefix, locale, messageType, loader);
    return message;
  }

  // ... throwable standard message as text

  /**
   * Returns the localized message for the given locale as formatted multi-line
   * text.
   *
   * @return returns the localized message of this exception.
   * @see de.smartics.exceptions.i18n.AbstractMessageException#getLocalizedMessage(java.util.Locale)
   */
  public final String getLocalizedTextMessage()
  {
    return getLocalizedTextMessage(Locale.getDefault());
  }

  /**
   * Returns the localized message for the given locale as formatted multi-line
   * text.
   *
   * @param locale locale the locale for which the message is requested.
   * @return returns the localized message of this exception.
   * @see #getLocalizedMessage(java.util.Locale, ClassLoader)
   */
  public final String getLocalizedTextMessage(final Locale locale)
  {
    return getLocalizedTextMessage(locale, Thread.currentThread()
        .getContextClassLoader());
  }

  /**
   * Returns the localized message for the given locale as formatted multi-line
   * text.
   *
   * @param locale locale the locale for which the message is requested.
   * @param loader loader the loader to read the message bundle.
   * @return returns the localized message of this exception.
   * @see #getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader)
   */
  public final String getLocalizedTextMessage(final Locale locale,
      final ClassLoader loader)
  {
    final String message =
        messageBean.getLocalizedInfo().getLocalizedTextMessage(this, locale,
            loader);
    return message;
  }

  @Override
  public final String getMessages()
  {
    return getMessages(Locale.getDefault());
  }

  @Override
  public final String getMessages(final Locale locale)
  {
    final StringBuilder buffer = new StringBuilder();
    for (MessageType type : MessageType.values())
    {
      buffer.append(type.name()).append('=').append(getMessage(locale, type))
          .append('\n');
    }
    return StringUtils.chop(buffer.toString());
  }

  @Override
  public final Messages createMessages()
  {
    return createMessages(Locale.getDefault());
  }

  @Override
  public final Messages createMessages(final Locale locale)
  {
    final Messages.Builder builder = new Messages.Builder();
    final String keyPrefix = getCode().getCode();
    for (MessageType type : MessageType.values())
    {
      builder.put(
          type,
          messageBean.getLocalizedInfo().createLocalizedMessage(this,
              keyPrefix, locale, type, null));
    }

    return builder.build();
  }

  @Override
  public final CauseTrailMessages getCauseTrail()
  {
    return getCauseTrail(Locale.getDefault());
  }

  @Override
  public final CauseTrailMessages getCauseTrail(final Locale locale)
  {
    return messageBean.getCauseTrail(locale);
  }

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

  /**
   * 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 I18nCodeMessageFormatter} should be set to the
   * {@link de.smartics.exceptions.ExceptionContext}.
   * </p>
   *
   * @return the string representation of the object.
   */
  @Override
  public String toString()
  {
    final I18nCodeMessageFormatter formatter =
        I18nExceptionContextManager.getFormatter(Thread.currentThread()
            .getContextClassLoader());
    final String string = formatter.format(this, messageBean);
    return string;
  }
}
File Line
de\smartics\exceptions\i18n\AbstractLocalizedException.java 408
de\smartics\exceptions\i18n\AbstractLocalizedRuntimeException.java 331
  public Messages createMessages()
  {
    return createMessages(Locale.getDefault());
  }

  @Override
  public final Messages createMessages(final Locale locale)
  {
    final Messages.Builder builder = new Messages.Builder();
    final String keyPrefix = getCode().getCode();
    for (MessageType type : MessageType.values())
    {
      builder.put(type, localizedInfo.createLocalizedMessage(this, keyPrefix,
          locale, type, null));
    }

    return builder.build();
  }

  @Override
  public final CauseTrailMessages getCauseTrail()
  {
    return getCauseTrail(Locale.getDefault());
  }

  @Override
  public final CauseTrailMessages getCauseTrail(final Locale locale)
  {
    return localizedInfo.getCauseTrail(locale);
  }

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

  /**
   * 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 I18nCodeMessageFormatter} should be set to the
   * {@link de.smartics.exceptions.ExceptionContext}.
   * </p>
   *
   * @return the string representation of the object.
   */
  @Override
  public String toString()
  {
    final I18nCodeMessageFormatter formatter =
        I18nExceptionContextManager.getFormatter(Thread.currentThread()
            .getContextClassLoader());
    final String string = formatter.format(this);
    return string;
  }
}
File Line
de\smartics\exceptions\i18n\AbstractMessageException.java 87
de\smartics\exceptions\i18n\AbstractMessageRuntimeException.java 87
  public MessageBean getMessageBean()
  {
    return messageBean;
  }

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

  // ... get message ..........................................................

  /**
   * {@inheritDoc}
   * <p>
   * Returns the localized message for the default locale.
   * </p>
   */
  @Override
  public final String getMessage()
  {
    return getLocalizedMessage();
  }

  /**
   * Calls
   * {@link de.smartics.exceptions.i18n.AbstractMessageException#getMessage(java.util.Locale, de.smartics.exceptions.i18n.message.MessageType)}
   * with argument list ({@link Locale#getDefault()}, &lt;messageType&gt;).
   *
   * @param messageType the type of message to fetch.
   * @return the message for the given type.
   * @see de.smartics.exceptions.i18n.AbstractMessageException#getMessage(java.util.Locale,
   *      de.smartics.exceptions.i18n.message.MessageType)
   */
  public final String getMessage(final MessageType messageType)
  {
    return getMessage(Locale.getDefault(), messageType);
  }

  @Override
  public final String getMessage(final Locale locale,
      final MessageType messageType)
  {
    return getLocalizedMessage(messageBean.getLocalizedInfo().getResourceKey(),
        locale, messageType, null); // , null);
  }

  // ... throwable standard message

  /**
   * Returns the localized message for the given locale.
   * <p>
   * Calls {@link #getLocalizedMessage(java.util.Locale)} with argument list (
   * {@link Locale#getDefault()}).
   * </p>
   *
   * @return returns the localized message of this exception.
   * @see de.smartics.exceptions.i18n.AbstractMessageException#getLocalizedMessage(java.util.Locale)
   */
  @Override
  public final String getLocalizedMessage()
  {
    return getLocalizedMessage(Locale.getDefault());
  }

  /**
   * Returns the localized message for the given locale.
   * <p>
   * Calls {@link #getLocalizedMessage(java.util.Locale,ClassLoader)} with
   * argument list (&lt;locale&gt;, <code>null</code>).
   * </p>
   *
   * @param locale locale the locale for which the message is requested.
   * @return returns the localized message of this exception.
   * @see #getLocalizedMessage(java.util.Locale, ClassLoader)
   */
  public final String getLocalizedMessage(final Locale locale)
  {
    return getLocalizedMessage(locale, Thread.currentThread()
        .getContextClassLoader()); // , null);
  }

  /**
   * Returns the localized message for the given locale.
   * <p>
   * Calls
   * {@link #getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader)}
   * with argument list (<code>null</code>, &lt;locale&gt;, MessageType.SUMMARY,
   * &lt;loader&gt;).
   *
   * @param locale locale the locale for which the message is requested.
   * @param loader loader the loader to read the message bundle.
   * @return returns the localized message of this exception.
   * @see #getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader)
   */
  public final String getLocalizedMessage(final Locale locale,
      final ClassLoader loader)
  {
    return messageBean.getLocalizedInfo().getLocalizedMessage(messageBean,
File Line
de\smartics\exceptions\i18n\message\MessageType.java 196
de\smartics\exceptions\i18n\message\MessageType.java 251
      final MessageParam messageParam)
  {
    String specificIndexString;
    if (TITLE == this)
    {
      specificIndexString = messageParam.headerParamIndex();
    }
    else if (SUMMARY == this)
    {
      specificIndexString = messageParam.summaryParamIndex();
    }
    else if (DETAILS == this)
    {
      specificIndexString = messageParam.detailsParamIndex();
    }
    else if (IMPLICATIONS_ON_CURRENT_TASK == this)
    {
      specificIndexString = messageParam.implicationsParamIndex();
    }
    else if (WHAT_TO_DO_NOW == this)
    {
      specificIndexString = messageParam.todoParamIndex();
    }
    else if (URL == this)
    {
      specificIndexString = messageParam.urlParamIndex();
    }
    else
    {
      assert false : "Unexpected enumeration type: " + this;
      specificIndexString = null; // NOPMD
    }

    if ("".equals(specificIndexString))
    {
      specificIndexString = messageParam.value();
    }
    final List<MessageParamInfo> infos =
File Line
de\smartics\exceptions\i18n\app\ConfigurationExceptionCode.java 132
de\smartics\exceptions\i18n\app\ParseExceptionCode.java 114
  private ConfigurationExceptionCode(final String componentId,
      final Integer majorNumber, final Integer minorNumber)
  {
    this.info = new NumberCodeInfo(componentId, majorNumber, minorNumber);
  }

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

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

  /**
   * Used to access the identify for the exceptions raised by this component.
   *
   * @return the component identifier of this exception library.
   */
  private static String readComponentId()
  {
    return Constant.COMPONENT_ID;
  }

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

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

  /**
   * {@inheritDoc}
   */
  // @Override Java 6 feature
  public String getCode()
  {
    return info.getCode();
  }

  /**
   * {@inheritDoc}
   */
  // @Override Java 6 feature
  public String getComponentId()
  {
    return info.getComponentId();
  }

  /**
   * {@inheritDoc}
   *
   * @see de.smartics.exceptions.code.NumberCode#getMajorNumber()
   */
  // @Override Java 6 feature
  public Integer getMajorNumber()
  {
    return info.getMajorNumber();
  }

  /**
   * {@inheritDoc}
   *
   * @see de.smartics.exceptions.code.NumberCode#getMinorNumber()
   */
  // @Override Java 6 feature
  public Integer getMinorNumber()
  {
    return info.getMinorNumber();
  }

  /**
   * {@inheritDoc}
   *
   * @see de.smartics.exceptions.core.Code#getDisplayId()
   */
  public String getDisplayId()
  {
    return info.getDisplayId();
  }

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

  /**
   * Returns the string representation of the object.
   *
   * @return the string representation of the object.
   */
  @Override
  public String toString()
  {
    return info.toString();
  }
}