commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (Jira)" <>
Subject [jira] [Work logged] (IMAGING-159) There should be a Parameters class
Date Sun, 01 Aug 2021 11:52:00 GMT


ASF GitHub Bot logged work on IMAGING-159:

                Author: ASF GitHub Bot
            Created on: 01/Aug/21 11:51
            Start Date: 01/Aug/21 11:51
    Worklog Time Spent: 10m 
      Work Description: darkma773r commented on a change in pull request #116:

File path: src/main/java/org/apache/commons/imaging/
@@ -79,25 +78,18 @@
  * that the documentation is perfect, especially in the more obscure
  * and specialized areas of implementation.
- * <h3>The "Map params" argument</h3>
+ * <h3>The "params" argument</h3>
- * Many of the methods specified by this class accept an argument of
- * type Map giving a list of parameters to be used when processing an
- * image. For example, some of the output formats permit the specification
+ * <p>Many of the methods specified by this class accept an argument of
+ * type {@code T} defining the parameters to be used when
+ * processing an image. For example, some of the output formats permit
  * of different kinds of image compression or color models. Some of the
  * reading methods permit the calling application to require strict
- * format compliance.   In many cases, however, an application will not
- * require the use of this argument.  While some of the ImageParser
- * implementations check for (and ignore) null arguments for this parameter,
- * not all of them do (at least not at the time these notes were written).
- * Therefore, a prudent programmer will always supply an valid, though
- * empty instance of a Map implementation when calling such methods.
- * Generally, the java HashMap class is useful for this purpose.
+ * format compliance.</p>
- * <p>Additionally, developers creating or enhancing classes derived
- * from ImageParser are encouraged to include such checks in their code.
+ * @param <T> type of parameters used by this image parser
-public abstract class ImageParser extends BinaryFileParser {
+public abstract class ImageParser<T extends ImagingParameters> extends BinaryFileParser

Review comment:
       A couple more thoughts here: 
   - I like the idea of having the TIFF and JPEG parameters extend a common ancestor if possible.
That seems like a more maintainable solution. With the current hierarchy, if a property needed
to be added to the TIFF parameters, it would also be added to the JPEG one, regardless of
whether or not it applied to that format.
   - With the removal of the `imageFormat` property, we could completely remove all of the
`ImagingParameters` subclasses that do not add any properties, such as `BmpImagingParameters`.
They do not seem to add much value anymore and could easily be added later if needed.

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail:

For queries about this service, please contact Infrastructure at:

Issue Time Tracking

    Worklog Id:     (was: 632056)
    Time Spent: 8h 40m  (was: 8.5h)

> There should be a Parameters class
> ----------------------------------
>                 Key: IMAGING-159
>                 URL:
>             Project: Commons Imaging
>          Issue Type: Improvement
>          Components: imaging.*
>    Affects Versions: 1.0-alpha2
>            Reporter: Benedikt Ritter
>            Assignee: Bruno P. Kinoshita
>            Priority: Major
>              Labels: github
>             Fix For: 1.0-alpha3
>          Time Spent: 8h 40m
>  Remaining Estimate: 0h
> Currently options for image I/O are defined as Maps. The leads to the problem that our
code has to validate parameter types when they are used:
> {code:java}
> final Object value = params.get(PARAM_KEY_COMPRESSION);
> if (value != null) {
>   if (!(value instanceof Number)) {
>     throw new ImageWriteException(
>       "Invalid compression parameter, must be numeric: "
>          + value);
>   }
>   compression = ((Number) value).intValue();
> }
> {code}
> This can be simplified if we define a Parameters class that provides additional methods
like {{public int getInt(String key)}}. The implementation could then look up the value from
the map through an exception if it is null or not a number.

This message was sent by Atlassian Jira

View raw message