at.newmedialab.ldpath.model.transformers.ByteTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ldpath-core-bundle Show documentation
Show all versions of ldpath-core-bundle Show documentation
Core Implementation of LD Path a simple path-based query language similar to XPath or SPARQL Property Paths that is particularly well-suited for querying and retrieving resources from the Linked Data Cloud by following RDF links between resources and servers.
package at.newmedialab.ldpath.model.transformers;
import at.newmedialab.ldpath.api.backend.RDFBackend;
import at.newmedialab.ldpath.api.transformers.NodeTransformer;
public class ByteTransformer implements NodeTransformer {
@Override
public Byte transform(RDFBackend backend, Node node) throws IllegalArgumentException {
if(backend.isLiteral(node)) {
return backend.decimalValue(node).byteValueExact();
} else {
throw new IllegalArgumentException("cannot transform node of type "+
node.getClass().getCanonicalName()+" to byte");
}
}
}