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 100
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRadioRenderer.java Tobago Core 100
        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) {
        final 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/internal/renderkit/renderer/SelectManyRendererBase.java Tobago Core 584
org/apache/myfaces/tobago/internal/util/SelectItemUtils.java Tobago Core 166
          if (value instanceof SelectItem) {
            nextItem = (SelectItem) value;
            return true;
          } else if (value != null && value.getClass().isArray()) {
            // value is any kind of array (primitive or non-primitive)
            // --> we have to use class Array to get the values
            final int length = Array.getLength(value);
            final Collection<Object> items = new ArrayList<>(length);
            for (int i = 0; i < length; i++) {
              items.add(Array.get(value, i));
            }
            nestedItems = items.iterator();
            return hasNext();
          } else if (value instanceof Iterable) {
            // value is Iterable --> Collection, DataModel,...
            nestedItems = ((Iterable<?>) value).iterator();
            return hasNext();
          } else if (value instanceof Map) {
            final Map<Object, Object> map = (Map<Object, Object>) value;
            final Collection<SelectItem> items = new ArrayList<>(map.size());
            for (final Map.Entry<Object, Object> entry : map.entrySet()) {
              items.add(new SelectItem(entry.getValue(), entry.getKey().toString()));
File Project Line
org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java Tobago Core 317
org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java Tobago Core 412
          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/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 114
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) {
        final 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/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/internal/renderkit/renderer/SelectManyCheckboxRenderer.java Tobago Core 78
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRadioRenderer.java Tobago Core 79
    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 754
  private static void getPathToComponent(final UIComponent component, final StringBuilder builder) {
    if (component == null) {
      return;
    }

    final 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/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/renderkit/renderer/SelectManyCheckboxRenderer.java Tobago Core 51
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRadioRenderer.java Tobago Core 52
    final String id = select.getClientId(facesContext);
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    final boolean disabled = select.isDisabled();
    final boolean readonly = select.isReadonly();
    final boolean required = select.isRequired();
    final boolean inline = select.isInline();
    final Markup markup = select.getMarkup();

    writer.startElement(HtmlElements.DIV);
    if (select.isLabelLayoutSkip()) {
      writer.writeIdAttribute(id);
      writer.writeAttribute(DataAttributes.MARKUP, JsonUtils.encode(markup), false);
    }

    writer.writeClassAttribute(
        TobagoClass.SELECT_MANY_CHECKBOX,
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,