jcabi-xml icon indicating copy to clipboard operation
jcabi-xml copied to clipboard

ClasspathInput.java fixes

Open amihaiemil opened this issue 9 years ago • 4 comments

com.jcabi.xml.ClasspathInput is currently filled with methods which are "//intentionally empty" or return null. Some of them can be properly implemented, some of them I think should throw UnsupportedOperationException.

  1. Parameters baseURI and encoding can be specified in the constructor when instanciating the class in ClasspathResolver.resolveResource:
class ClasspathResolver implements LSResourceResolver {
    @Override
    @SuppressWarnings("PMD.UseObjectForClearerAPI")
    // @checkstyle ParameterNumber (1 line)
    public LSInput resolveResource(final String type, final String namespaceuri,
        final String publicid, final String systemid, final String baseuri) {
        LSInput input = null;
        if (systemid != null && getClass().getResource(systemid) != null) {
            input = new ClasspathInput(publicid, systemid, "UTF-8", baseuri);
        }
        return input;
    }
}

Then the getters and setters for the 2 can be properly implemented inside ClasspathInput .. also, encoding would be used by getStringData() rather than hardcoding "UTF-8" there.

  1. All other unimplemented setters can throw new UnsupportedOperationException();
  2. getCharacterStream() and getByteStream() should remain as they are or should return a mock of Reader/inputStream - they cannot throw UnsupportedOperationException since then tests fail (they are evantually called by the XML validators...)

I did these changes and the build was successfull.

amihaiemil avatar Mar 29 '16 14:03 amihaiemil

@dmarkov Can you do something about this pls? Thanks.

amihaiemil avatar Mar 31 '16 20:03 amihaiemil

@yegor256 please take a look at it and dispatch (see par.21)

dmarkov avatar Apr 04 '16 07:04 dmarkov

@yegor256 Can you take a look here, pls? Thanks.

amihaiemil avatar Apr 18 '16 14:04 amihaiemil

@amihaiemil thanks for the report, I topped your acc for 15 mins, payment ID AP-5X422939NA2268401

dmarkov avatar Apr 19 '16 08:04 dmarkov