com.github.anno4j.model.AgentSupport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anno4j-core Show documentation
Show all versions of anno4j-core Show documentation
Read and write API for W3C Web Annotation Data Model (http://www.w3.org/TR/annotation-model/) and W3C Open Annotation Data Model (http://www.openannotation.org/spec/core/)
package com.github.anno4j.model;
import com.github.anno4j.annotations.Partial;
import com.github.anno4j.model.impl.ResourceObjectSupport;
import org.openrdf.repository.RepositoryException;
import org.openrdf.rio.*;
import java.io.ByteArrayOutputStream;
@Partial
public abstract class AgentSupport extends ResourceObjectSupport implements Agent {
/**
* Method returns a textual representation of the given Annotation, containing
* its Body, Target and possible Selection, in a supported serialisation format.
*
* @param format The format which should be printed.
* @return A textual representation if this object in the format.
*/
@Override
public String getTriples(RDFFormat format) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
RDFParser parser = Rio.createParser(RDFFormat.NTRIPLES);
RDFWriter writer = Rio.createWriter(format, out);
parser.setRDFHandler(writer);
try {
this.getObjectConnection().exportStatements(this.getResource(), null, null, true, writer);
} catch (RepositoryException | RDFHandlerException e) {
e.printStackTrace();
}
return out.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy