commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stain <>
Subject [GitHub] commons-rdf pull request #27: COMMONSRDF-47 RDFSyntax as an interface
Date Thu, 09 Feb 2017 00:47:49 GMT
Github user stain commented on a diff in the pull request:
    --- Diff: api/src/main/java/org/apache/commons/rdf/api/ ---
    @@ -178,17 +206,62 @@ private RDFSyntax(final String name, final String mediaType, final
String fileEx
          * The <code>fileExtension</code> is compared in lower case, therefore
          * might not be equal to the {@link RDFSyntax#fileExtension} of the returned
          * RDFSyntax.
    +     * <p>
    +     * The list of syntaxes supported is at least those returned by
    +     * {@link #w3cSyntaxes()}.
          * @param fileExtension
          *            The fileExtension to match, starting with <code>.</code>
          * @return If {@link Optional#isPresent()}, the {@link RDFSyntax} which has
    -     *         a matching {@link RDFSyntax#fileExtension}, otherwise
    +     *         a matching {@link RDFSyntax#fileExtension()}, otherwise
          *         {@link Optional#empty()} indicating that no matching file
          *         extension was found.
         public static Optional<RDFSyntax> byFileExtension(final String fileExtension)
    -        final String ext = fileExtension.toLowerCase(Locale.ENGLISH);
    -        return -> t.fileExtension.equals(ext)).findAny();
    +        final String ext = fileExtension.toLowerCase(Locale.ROOT);        
    +        return w3cSyntaxes().stream().filter(t -> t.fileExtension().equals(ext))
    +                .findAny();
    +    }
    +    /**
    +     * Return the RDFSyntax with the specified {@link #name()}.
    +     * <p>
    +     * The list of syntaxes supported is at least those returned by
    --- End diff --
    Changed to 
    > This method support all syntaxes returned by {@link #w3cSyntaxes()}
    There is no good way from a static class method to allow user extension; at least without
having a discovery mechanism (classpath sensitive) or mutable setters/registrations (initialization
sensitive) - I would argue it is out of scope for this particular method to support that,
as Commons RDF only  target RDF 1.1.  
    If you want we could change these lookup method to take a variable/optional list of `Iterable<RDFSyntax>`
as parameters? 
    (The parser/writer methods would with this PR support `RDFSyntax` from "elsewhere" - e.g.
we could return supported syntaxes from each `RDF` instance)

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message