Commons CSV
  1. Commons CSV
  2. CSV-117

Validate format parameters in constructor

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Parser
    • Labels:
      None

      Description

      As per ML discussion, here is a patch which moves CSVFormat parameter validation into the constructor. Tests still work once ISE replaced by IAE in the expected exceptions.

        Activity

        Hide
        Sebb added a comment -

        No further comments, so applied the change:

        URL: http://svn.apache.org/r1603967
        Log:
        CSV-117 Validate format parameters in constructor

        Modified:
        commons/proper/csv/trunk/src/changes/changes.xml
        commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
        commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
        commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java
        commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java

        Show
        Sebb added a comment - No further comments, so applied the change: URL: http://svn.apache.org/r1603967 Log: CSV-117 Validate format parameters in constructor Modified: commons/proper/csv/trunk/src/changes/changes.xml commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
        Hide
        Sebb added a comment -

        The order is not constrained initially, except that escape must be set before using Quote.NONE

        Changes to parameters that have already been set are constrained in that each change is validated against the other parameters.

        This was discussed on the ML.

        The purpose of this change is to find problem settings as early as possible, rather than when the format is used.
        I could see no other way of doing this other than by using a build() method.
        However, IIRC that was voted down some while back.

        Show
        Sebb added a comment - The order is not constrained initially, except that escape must be set before using Quote.NONE Changes to parameters that have already been set are constrained in that each change is validated against the other parameters. This was discussed on the ML. The purpose of this change is to find problem settings as early as possible, rather than when the format is used. I could see no other way of doing this other than by using a build() method. However, IIRC that was voted down some while back.
        Hide
        Emmanuel Bourg added a comment -

        Does this restrict the order in which the parameters can be specified? If so I don't think this is a good idea.

        Show
        Emmanuel Bourg added a comment - Does this restrict the order in which the parameters can be specified? If so I don't think this is a good idea.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sebb
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development