CPD Results

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

Duplications

File Project Line
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyCheckboxRenderer.java Tobago Core 97
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRadioRenderer.java Tobago Core 97
        checked = ArrayUtils.contains(submittedValues, formattedValue);
      }
      writer.writeAttribute(HtmlAttributes.CHECKED, checked);
      writer.writeNameAttribute(id);
      writer.writeIdAttribute(itemId);
      writer.writeAttribute(HtmlAttributes.VALUE, formattedValue, true);
      writer.writeAttribute(HtmlAttributes.DISABLED, itemDisabled);
      writer.writeAttribute(HtmlAttributes.READONLY, readonly);
      writer.writeAttribute(HtmlAttributes.REQUIRED, required);
      if (first) {
        HtmlRendererUtils.renderFocus(id, select.isFocus(), ComponentUtils.isError(select), facesContext, writer);
        first = false;
      }
      writer.writeAttribute(HtmlAttributes.TABINDEX, select.getTabIndex());
      writer.writeCommandMapAttribute(JsonUtils.encode(RenderUtils.getBehaviorCommands(facesContext, select)));
      writer.endElement(HtmlElements.INPUT);

      writer.startElement(HtmlElements.I);
      writer.writeClassAttribute(TobagoClass.INPUT_PSEUDO);
      writer.endElement(HtmlElements.I);

      if (item instanceof org.apache.myfaces.tobago.model.SelectItem) {
        org.apache.myfaces.tobago.model.SelectItem tobagoItem = (org.apache.myfaces.tobago.model.SelectItem) item;
        final String image = tobagoItem.getImage();

        if (image != null) {
          writer.startElement(HtmlElements.IMG);
          writer.writeAttribute(HtmlAttributes.SRC, image, true);
          writer.writeAttribute(HtmlAttributes.ALT, "", false);
          writer.endElement(HtmlElements.IMG);
        }
      }

      final String label = item.getLabel();
      if (label != null) {
        writer.writeText(label);
      }

      writer.endElement(HtmlElements.LABEL);
      if (renderOuterItem()) {
        writer.endElement(HtmlElements.DIV);
      }
    }
  }

  @Override
File Project Line
org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java Tobago Example Demo 118
org/apache/myfaces/tobago/example/test/ClientConfigController.java Tobago Example Demo 79
    theme = tobagoContext.getTheme();
  }

  public List<SelectItem> getLocaleItems() {
    final FacesContext facesContext = FacesContext.getCurrentInstance();
    final Application application = facesContext.getApplication();
    final Locale defaultLocale = application.getDefaultLocale();
    final Iterator supportedLocales = application.getSupportedLocales();

    boolean defaultInList = false;
    final List<SelectItem> localeItems = new ArrayList<SelectItem>();
    while (supportedLocales.hasNext()) {
      final Locale locale = (Locale) supportedLocales.next();
      localeItems.add(createLocaleItem(locale));
      if (locale.equals(defaultLocale)) {
        defaultInList = true;
      }
    }
    // If the default is already in the list, don't add it.
    // Background: Must the default be in the supported list? Yes or No?
    // This question is not specified explicit and different implemented in the RI and MyFaces
    if (!defaultInList && defaultLocale != null) {
      localeItems.add(0, createLocaleItem(defaultLocale));
    }
    return localeItems;
  }

  private SelectItem createLocaleItem(final Locale localeItem) {
    if (locale != null) {
      return new SelectItem(localeItem, localeItem.getDisplayName(locale));
    } else {
      return new SelectItem(localeItem, localeItem.getDisplayName(localeItem));
    }
  }

  public static ClientConfigController getCurrentInstance(
File Project Line
org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java Tobago Core 310
org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java Tobago Core 405
          final Object[] args = {inputMarker, last1 == -1 ? "?" : last1, unknown ? "" : sheet.getRowCount()};
          final MessageFormat detail = new MessageFormat(
              TobagoResourceBundle.getString(facesContext, key), locale);
          final String formatted = detail.format(args);
          final int pos = formatted.indexOf(inputMarker);
          if (pos >= 0) {
            writer.writeText(formatted.substring(0, pos));
            writer.startElement(HtmlElements.SPAN);
            writer.writeClassAttribute(TobagoClass.SHEET__PAGING_OUTPUT);
            writer.writeText(Integer.toString(first));
            writer.endElement(HtmlElements.SPAN);
            writer.startElement(HtmlElements.INPUT);
            writer.writeIdAttribute(pagerCommandId);
            writer.writeNameAttribute(pagerCommandId);
            writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.TEXT);
            writer.writeClassAttribute(TobagoClass.SHEET__PAGING_INPUT);
            writer.writeAttribute(HtmlAttributes.VALUE, first);
            if (!unknown) {
              writer.writeAttribute(HtmlAttributes.MAXLENGTH, Integer.toString(sheet.getRowCount()).length());
File Project Line
org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java Tobago Example Demo 157
org/apache/myfaces/tobago/example/test/ClientConfigController.java Tobago Example Demo 112
  }

  public Theme getTheme() {
    return theme;
  }

  public String getLocalizedTheme() {
    for (int i = 0; i < themeItems.length; i++) {
      final SelectItem themeItem = themeItems[i];
      if (ObjectUtils.equals(themeItem.getValue(), theme)) {
        return themeItem.getLabel();
      }
    }
    return "???";
  }

  public void setTheme(final Theme theme) {
    this.theme = theme;
  }

  public SelectItem[] getThemeItems() {
    return themeItems;
  }

  public void setThemeItems(final SelectItem[] themeItems) {
    this.themeItems = themeItems;
  }

  public Locale getLocale() {
    return locale;
  }

  public String getLocalizedLocale() {
    if (locale != null) {
      return locale.getDisplayName(locale);
    } else{
      return null;
    }
  }

  public void setLocale(final Locale locale) {
    this.locale = locale;
  }

}
File Project Line
org/apache/myfaces/tobago/apt/processor/CheckstyleConfigGenerator.java Tobago Tool Apt 274
org/apache/myfaces/tobago/apt/processor/TaglibGenerator.java Tobago Tool Apt 383
        throw new IllegalArgumentException("Only setter allowed found: " + simpleName);
      }
    }
  }

  private List<? extends javax.lang.model.element.Element> getAllMembers(final TypeElement type) {
    final List<? extends javax.lang.model.element.Element> members
        = new ArrayList<javax.lang.model.element.Element>(processingEnv.getElementUtils().getAllMembers(type));
    Collections.sort(members, new Comparator<javax.lang.model.element.Element>() {
      @Override
      public int compare(final javax.lang.model.element.Element d1, final javax.lang.model.element.Element d2) {
        return d1.getSimpleName().toString().compareTo(d2.getSimpleName().toString());
      }
    });
    return members;
  }

  private void addLib(final Taglib taglibAnnotation, final Element parent, final Document document) {
File Project Line
org/apache/myfaces/tobago/internal/webapp/HtmlResponseWriter.java Tobago Core 49
org/apache/myfaces/tobago/internal/webapp/XmlResponseWriter.java Tobago Core 38
  }

  @Override
  public void writeText(final Object text, final String property)
      throws IOException {
    closeOpenTag();
    final String value = findValue(text, property);
    helper.writeText(value);
  }

  @Override
  public void writeText(final char[] text, final int offset, final int length)
      throws IOException {
    closeOpenTag();
    helper.writeText(text, offset, length);
  }

  @Override
  public void write(final char[] cbuf, final int off, final int len) throws IOException {
    // Related to http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-696
    if (Arrays.equals(cbuf, XML_VERSION_1_0_ENCODING_UTF_8_CHARS)) {
      // drop
    } else {
      super.write(cbuf, off, len);
    }
  }

  @Override
  protected void closeEmptyTag() throws IOException {
    getWriter().write(">");
File Project Line
org/apache/myfaces/tobago/internal/renderkit/renderer/InRenderer.java Tobago Core 108
org/apache/myfaces/tobago/internal/renderkit/renderer/TextareaRenderer.java Tobago Core 112
    int maxLength = 0;
    int minLength = 0;
    String pattern = null;
    for (final Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        final LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
        minLength = lengthValidator.getMinimum();
      } else if (validator instanceof RegexValidator) {
          RegexValidator regexValidator = (RegexValidator) validator;
          pattern = regexValidator.getPattern();
      }
    }
    if (maxLength > 0) {
      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
    }
    if (minLength > 0) {
      writer.writeAttribute(HtmlAttributes.MINLENGTH, minLength);
    }
    if (pattern != null) {
      writer.writeAttribute(HtmlAttributes.PATTERN, pattern, true);
    }
    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
File Project Line
org/apache/myfaces/tobago/internal/component/AbstractUIPage.java Tobago Core 60
org/apache/myfaces/tobago/internal/component/AbstractUIPanelBase.java Tobago Core 34
  @Override
  public void encodeBegin(final FacesContext facesContext) throws IOException {
    super.encodeBegin(facesContext);
    final UIComponent layoutManager = LayoutUtils.getLayoutManager(this);
    if (layoutManager != null) {
      layoutManager.encodeBegin(facesContext);
    }
  }

  @Override
  public void encodeChildren(final FacesContext facesContext) throws IOException {
    final UIComponent layoutManager = LayoutUtils.getLayoutManager(this);
    if (layoutManager != null) {
      layoutManager.encodeChildren(facesContext);
    } else {
      super.encodeChildren(facesContext);
    }
  }

  @Override
  public void encodeEnd(final FacesContext facesContext) throws IOException {
    final UIComponent layoutManager = LayoutUtils.getLayoutManager(this);
    if (layoutManager != null) {
      layoutManager.encodeEnd(facesContext);
    }
    super.encodeEnd(facesContext);
File Project Line
org/apache/myfaces/tobago/event/ValueExpressionSheetStateChangeListener.java Tobago Core 51
org/apache/myfaces/tobago/event/ValueExpressionTabChangeListener.java Tobago Core 51
      LOG.error("Ignoring SheetStateChangeEvent. No SheetStateChangeListener found.");
    }
  }

  @Override
  public Object saveState(final FacesContext context) {
    final Object[] state = new Object[2];
    state[0] = UIComponentBase.saveAttachedState(context, valueExpression);
    state[1] = type;
    return state;
  }

  @Override
  public void restoreState(final FacesContext context, final Object state) {
    final Object[] values = (Object[]) state;
    valueExpression = (ValueExpression) UIComponentBase.restoreAttachedState(context, values[0]);
    type = (String) values[1];

  }

  @Override
  public boolean isTransient() {
    return false;
  }

  @Override
  public void setTransient(final boolean newTransientValue) {
    // ignore
  }

  private SheetStateChangeListener getSheetStateChangeListener() {
File Project Line
org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java Tobago Example Demo 42
org/apache/myfaces/tobago/example/test/ClientConfigController.java Tobago Example Demo 38
  private Theme theme;
  private SelectItem[] themeItems;

  private Locale locale;

  public ClientConfigController() {

    // theme

    final FacesContext facesContext = FacesContext.getCurrentInstance();
    final TobagoConfig tobagoConfig = TobagoConfig.getInstance(facesContext);

    final List<Theme> themes = new ArrayList<Theme>(tobagoConfig.getSupportedThemes());
    themes.add(0, tobagoConfig.getDefaultTheme());
    themeItems = new SelectItem[themes.size()];
    for (int i = 0; i < themeItems.length; i++) {
      final Theme themeItem = themes.get(i);
      themeItems[i] = new SelectItem(themeItem, themeItem.getDisplayName());
    }
File Project Line
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyCheckboxRenderer.java Tobago Core 75
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRadioRenderer.java Tobago Core 76
    for (final SelectItem item : SelectItemUtils.getItemIterator(facesContext, select)) {
      final boolean itemDisabled = item.isDisabled() || disabled;
      final String itemId = id + ComponentUtils.SUB_SEPARATOR + i++;
      if (renderOuterItem()) {
        writer.startElement(HtmlElements.DIV);
        writer.writeClassAttribute(
            BootstrapClass.FORM_CHECK,
            inline ? BootstrapClass.FORM_CHECK_INLINE : null,
            itemDisabled ? BootstrapClass.DISABLED : null);
      }
      writer.startElement(HtmlElements.LABEL);
      writer.writeClassAttribute(
          BootstrapClass.FORM_CHECK_LABEL,
          getCssItems(facesContext, select));
      writer.startElement(HtmlElements.INPUT);
      writer.writeClassAttribute(BootstrapClass.FORM_CHECK_INPUT);
      writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.CHECKBOX);
File Project Line
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRendererBase.java Tobago Core 465
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRendererBase.java Tobago Core 753
  private static void getPathToComponent(UIComponent component, StringBuilder builder) {
    if (component == null) {
      return;
    }

    StringBuilder intBuilder = new StringBuilder();

    intBuilder.append("[Class: ");
    intBuilder.append(component.getClass().getName());
    if (component instanceof UIViewRoot) {
      intBuilder.append(",ViewId: ");
      intBuilder.append(((UIViewRoot) component).getViewId());
    } else {
      intBuilder.append(",Id: ");
      intBuilder.append(component.getId());
    }
    intBuilder.append("]");

    builder.insert(0, intBuilder.toString());
File Project Line
org/apache/myfaces/tobago/example/demo/ThemeController.java Tobago Example Demo 41
org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java Tobago Example Demo 47
org/apache/myfaces/tobago/example/test/ClientConfigController.java Tobago Example Demo 43
  public ThemeController() {
    final FacesContext facesContext = FacesContext.getCurrentInstance();
    final TobagoConfig tobagoConfig = TobagoConfig.getInstance(facesContext);
    final List<Theme> themes = new ArrayList<Theme>(tobagoConfig.getSupportedThemes());
    themes.add(0, tobagoConfig.getDefaultTheme());
    themeItems = new SelectItem[themes.size()];
    for (int i = 0; i < themeItems.length; i++) {
      final Theme themeItem = themes.get(i);
      themeItems[i] = new SelectItem(themeItem, themeItem.getDisplayName());
    }
File Project Line
org/apache/myfaces/tobago/example/demo/sudoku/Sudoku.java Tobago Example Demo 50
org/apache/myfaces/tobago/example/demo/sudoku/Sudoku.java Tobago Example Demo 56
        0, 1, 2, 3, 4, 5, 6, 7, 8,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,

        -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,
File Project Line
org/apache/myfaces/tobago/example/demo/sudoku/Sudoku.java Tobago Example Demo 50
org/apache/myfaces/tobago/example/demo/sudoku/Sudoku.java Tobago Example Demo 56
        0, 1, 2, 3, 4, 5, 6, 7, 8,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,

        -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,
File Project Line
org/apache/myfaces/tobago/internal/webapp/DebugResponseWriterWrapper.java Tobago Core 71
org/apache/myfaces/tobago/internal/webapp/TobagoResponseWriterWrapper.java Tobago Core 72
    return new DebugResponseWriterWrapper((TobagoResponseWriter) responseWriter.cloneWithWriter(writer));
  }

  @Override
  @Deprecated
  public void writeAttribute(final String name, final Object value, final String property) throws IOException {
    responseWriter.writeAttribute(name, value, property);
  }

  @Override
  @Deprecated
  public void writeText(final Object text, final String property) throws IOException {
    responseWriter.writeText(text, property);
  }

  @Override
  public void flush() throws IOException {
    responseWriter.flush();
  }

  @Override
  public void writeAttribute(final MarkupLanguageAttributes name, final String value, final boolean escape)
      throws IOException {
File Project Line
org/apache/myfaces/tobago/example/demo/sudoku/Sudoku.java Tobago Example Demo 50
org/apache/myfaces/tobago/example/demo/sudoku/Sudoku.java Tobago Example Demo 56
        0, 1, 2, 3, 4, 5, 6, 7, 8,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,

        -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1,