Java Code Examples for org.eclipse.rdf4j.model.Statement#toString()

The following examples show how to use org.eclipse.rdf4j.model.Statement#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoParseUtils.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Parse GML/wkt literal to Geometry
 *
 * @param statement
 * @return
 * @throws ParseException
 * @throws ParserConfigurationException
 * @throws SAXException
 * @throws IOException
 */
public static Geometry getGeometry(final Statement statement, GmlToGeometryParser gmlToGeometryParser) throws ParseException {
    // handle GML or WKT
    final Literal lit = getLiteral(statement);
    if (GeoConstants.XMLSCHEMA_OGC_WKT.equals(lit.getDatatype())) {
        final String wkt = lit.getLabel().toString();
        return (new WKTReader()).read(wkt);
    } else if (GeoConstants.XMLSCHEMA_OGC_GML.equals(lit.getDatatype())) {
        final String gml = lit.getLabel().toString();
        try {
            return getGeometryGml(gml, gmlToGeometryParser);
        } catch (IOException | SAXException | ParserConfigurationException e) {
            throw new ParseException(e);
        }
    } else {
        throw new ParseException("Literal is unknown geo type, expecting WKT or GML: " + statement.toString());
    }
}
 
Example 2
Source File: GeoParseUtils.java    From rya with Apache License 2.0 5 votes vote down vote up
public static Literal getLiteral(final Statement statement) throws ParseException {
    final Value v = statement.getObject();
    if (!(v instanceof Literal)) {
        throw new ParseException("Statement does not contain Literal: " + statement.toString());
    }
    final Literal lit = (Literal) v;
    return lit;
}