CPD Results

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

Duplications

File Project Line
org/apache/myfaces/tobago/internal/util/HtmlWriterUtils.java Tobago Core 57
org/apache/myfaces/tobago/internal/util/JavascriptWriterUtils.java Tobago Core 53
org/apache/myfaces/tobago/internal/util/JsonWriterUtils.java Tobago Core 58
  public HtmlWriterUtils(final Writer out, final String characterEncoding) {
    super(out, characterEncoding);
  }

  @Override
  protected void writeEncodedValue(final char[] text, final int start,
      final int length, final boolean isAttribute) throws IOException {

    int localIndex = -1;

    final int end = start + length;
    for (int i = start; i < end; i++) {
      final char ch = text[i];
      if (ch >= CHARS_TO_ESCAPE.length || CHARS_TO_ESCAPE[ch] != null) {
        localIndex = i;
        break;
      }
    }
    final Writer out = getOut();

    if (localIndex == -1) {
      // no need to escape
      out.write(text, start, length);
    } else {
      // write until localIndex and then encode the remainder
      out.write(text, start, localIndex);

      final ResponseWriterBuffer buffer = getBuffer();

      for (int i = localIndex; i < end; i++) {
        final char ch = text[i];

        // Tilde or less...
        if (ch < CHARS_TO_ESCAPE.length) {
          if (isAttribute && ch == '&' && (i + 1 < end) && text[i + 1] == '{') {
            // HTML 4.0, section B.7.1: ampersands followed by
            // an open brace don't get escaped
            buffer.addToBuffer('&');
          } else if (CHARS_TO_ESCAPE[ch] != null) {
            buffer.addToBuffer(CHARS_TO_ESCAPE[ch]);
          } else {
            buffer.addToBuffer(ch);
          }
        } else if (isUtf8()) {
          buffer.addToBuffer(ch);
        } else if (ch <= 0xff) {
          // ISO-8859-1 entities: encode as needed
          buffer.flushBuffer();

          out.write('&');
          final char[] chars = ISO8859_1_ENTITIES[ch - 0xA0];
          out.write(chars, 0, chars.length);
          out.write(';');
        } else {
          buffer.flushBuffer();

          // Double-byte characters to encode.
          // PENDING: when outputting to an encoding that
          // supports double-byte characters (UTF-8, for example),
          // we should not be encoding
          writeDecRef(ch);
        }
      }

      buffer.flushBuffer();
    }
  }
}
File Project Line
org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java Tobago Core 311
org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java Tobago Core 406
          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/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/renderkit/renderer/SelectManyCheckboxRenderer.java Tobago Core 74
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);
      final List<CssItem> cssItems = new ArrayList<CssItem>();
      addCssItems(facesContext, select, cssItems);
      writer.writeClassAttribute(BootstrapClass.FORM_CHECK_LABEL,
          null,
          cssItems.toArray(new CssItem[cssItems.size()]));
      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/SelectManyCheckboxRenderer.java Tobago Core 98
org/apache/myfaces/tobago/internal/renderkit/renderer/SelectOneRadioRenderer.java Tobago Core 100
        checked = RenderUtils.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);
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/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
  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,