public LSInput resolveResource(String type, String namespaceURI, String publicId, final String systemId, final String baseURI) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "type={0} namespaceURI={1} publicId={2} systemId={3} baseURI={4}", new Object[]{type, namespaceURI, publicId, systemId, baseURI});
}
try {
final SDDocument doc;
if (systemId == null) {
doc = nsMapping.get(namespaceURI);
} else {
URI rel = (baseURI != null)
? new URI(baseURI).resolve(systemId)
: new URI(systemId);
doc = docs.get(rel.toString());
}
if (doc != null) {
return new LSInput() {
@Override
public Reader getCharacterStream() {
return null;
}
@Override
public void setCharacterStream(Reader characterStream) {
throw new UnsupportedOperationException();
}
@Override
public InputStream getByteStream() {
ByteArrayBuffer bab = new ByteArrayBuffer();
try {
doc.writeTo(null, resolver, bab);
} catch (IOException ioe) {
throw new WebServiceException(ioe);
}
return bab.newInputStream();
}
@Override
public void setByteStream(InputStream byteStream) {
throw new UnsupportedOperationException();
}
@Override
public String getStringData() {
return null;
}
@Override
public void setStringData(String stringData) {
throw new UnsupportedOperationException();
}
@Override
public String getSystemId() {
return doc.getURL().toExternalForm();
}
@Override
public void setSystemId(String systemId) {
throw new UnsupportedOperationException();
}
@Override
public String getPublicId() {
return null;
}
@Override
public void setPublicId(String publicId) {
throw new UnsupportedOperationException();
}
@Override
public String getBaseURI() {
return doc.getURL().toExternalForm();
}
@Override
public void setBaseURI(String baseURI) {
throw new UnsupportedOperationException();