Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8194909

TextMeasurer/deleteChar function fails when deleting more than one characters.

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • client-libs
    • None
    • 2d
    • behavioral
    • minimal
    • The change in this CSR updates specification to explicitly mention the outcome of executing the concerned methods with an invalid argument.
    • Java API
    • SE

      Summary

      Make the exceptional behavior of java.awt.font.TextMeasurer and java.awt.font.LineBreakMeasurer more explicitly specified for exception conditions on text insertion and deletion.

      Problem

      . The specification for the methods - insertChar and deleteChar of classes
           . java.awt.font.TextMeasurer and
           . java.awt.font.LineBreakMeasurer
      mention that the methods are to be used to insert or delete a single character from the respective objects.
      . However, the specification does not mention the outcome when a programmer attempts to insert or delete multiple characters from these objects.

      Solution

      . Update the specification to explicitly mention the outcome - IllegalArgumentException, when programmer attempts to insert or delete multiple characters from TextMeasurer and LineBreakMeasurer Objects.

      Specification

      File: TextMeasurer.java Method: insertChar

       /**
        * Updates the {@code TextMeasurer} after a single character has
        * been inserted
        * into the paragraph currently represented by this
        * {@code TextMeasurer}.
        ...
      ++ * @throws IllegalArgumentException if multiple characters are inserted
      ++ * in the text represented by {@code newParagraph}
         ...
        */

      File TextMeasurer.java Method: deleteChar
       /**
        * Updates the {@code TextMeasurer} after a single character has
        * been deleted
        * from the paragraph currently represented by this
        * {@code TextMeasurer}.
        ...
      ++ * @throws IllegalArgumentException if multiple characters are deleted from
      ++ * the text represented by {@code newParagraph}
        ...
        */

      File: LineBreakMeasurer.java Method: insertChar
        /**
         * Updates this {@code LineBreakMeasurer} after a single
         * character is inserted into the text, and sets the current
         * position to the beginning of the paragraph.
         ...
      ++ * @throws IllegalArgumentException if multiple characters are inserted
      ++ * in the text represented by {@code newParagraph}
         ...
         */

      File: LineBreakMeasurer.java Method: deleteChar
        /**
         * Updates this {@code LineBreakMeasurer} after a single
         * character is deleted from the text, and sets the current
         * position to the beginning of the paragraph.
         ...
      ++ * @throws IllegalArgumentException if multiple characters are deleted from
      ++ * the text represented by {@code newParagraph}
         ...
         */

            Unassigned Unassigned
            jwangsunw Jane Wang (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: