/** * Decode a previously encoded URI. * * @param encodedValue * the encoded value * @param valueFactory * the factory to use for constructing the URI * @return the decoded URI * @see #encodeValue(Value) */ public static IRI decodeURI(String encodedValue, ValueFactory valueFactory) { if (encodedValue != null) { return NTriplesUtil.parseURI(encodedValue, valueFactory); } return null; }
/** * Decode a previously encoded URI. * * @param encodedValue * the encoded value * @param valueFactory * the factory to use for constructing the URI * @return the decoded URI * @see #encodeValue(Value) */ public static IRI decodeURI(String encodedValue, ValueFactory valueFactory) { if (encodedValue != null) { return NTriplesUtil.parseURI(encodedValue, valueFactory); } return null; }
/** * Decode a previously encoded URI. * * @param encodedValue * the encoded value * @param valueFactory * the factory to use for constructing the URI * @return the decoded URI * @see #encodeValue(Value) */ public static IRI decodeURI(String encodedValue, ValueFactory valueFactory) { if (encodedValue != null) { return NTriplesUtil.parseURI(encodedValue, valueFactory); } return null; }
protected IRI parseIRI(final String s) { if (s.equals("null")) { return null; } return NTriplesUtil.parseURI(s, valueFactory); }
private List<IRI> initPredicates(JSONObject config) { List<IRI> predList = new ArrayList<>(); JSONArray preds = config.optJSONArray(PREDICATES); if (preds != null) { for (int i = 0; i < preds.length(); i++) { String uri_nt = preds.optString(i); IRI uri = NTriplesUtil.parseURI(uri_nt, vf); predList.add(uri); } } return predList; }
/** * Parses an N-Triples resource, creates an object for it using the supplied ValueFactory and returns this * object. * * @param nTriplesResource * The N-Triples resource to parse. * @param valueFactory * The ValueFactory to use for creating the object. * @return An object representing the parsed resource. * @throws IllegalArgumentException * If the supplied resource could not be parsed correctly. */ public static Resource parseResource(String nTriplesResource, ValueFactory valueFactory) throws IllegalArgumentException { if (nTriplesResource.startsWith("<")) { return parseURI(nTriplesResource, valueFactory); } else if (nTriplesResource.startsWith("_:")) { return parseBNode(nTriplesResource, valueFactory); } else { throw new IllegalArgumentException("Not a legal N-Triples resource: " + nTriplesResource); } }
/** * Parses an N-Triples resource, creates an object for it using the supplied ValueFactory and returns this * object. * * @param nTriplesResource * The N-Triples resource to parse. * @param valueFactory * The ValueFactory to use for creating the object. * @return An object representing the parsed resource. * @throws IllegalArgumentException * If the supplied resource could not be parsed correctly. */ public static Resource parseResource(String nTriplesResource, ValueFactory valueFactory) throws IllegalArgumentException { if (nTriplesResource.startsWith("<")) { return parseURI(nTriplesResource, valueFactory); } else if (nTriplesResource.startsWith("_:")) { return parseBNode(nTriplesResource, valueFactory); } else { throw new IllegalArgumentException("Not a legal N-Triples resource: " + nTriplesResource); } }
/** * Parses an N-Triples value, creates an object for it using the supplied ValueFactory and returns this * object. * * @param nTriplesValue * The N-Triples value to parse. * @param valueFactory * The ValueFactory to use for creating the object. * @return An object representing the parsed value. * @throws IllegalArgumentException * If the supplied value could not be parsed correctly. */ public static Value parseValue(String nTriplesValue, ValueFactory valueFactory) throws IllegalArgumentException { if (nTriplesValue.startsWith("<")) { return parseURI(nTriplesValue, valueFactory); } else if (nTriplesValue.startsWith("_:")) { return parseBNode(nTriplesValue, valueFactory); } else if (nTriplesValue.startsWith("\"")) { return parseLiteral(nTriplesValue, valueFactory); } else { throw new IllegalArgumentException("Not a legal N-Triples value: " + nTriplesValue); } }
/** * Parses an N-Triples value, creates an object for it using the supplied ValueFactory and returns this * object. * * @param nTriplesValue * The N-Triples value to parse. * @param valueFactory * The ValueFactory to use for creating the object. * @return An object representing the parsed value. * @throws IllegalArgumentException * If the supplied value could not be parsed correctly. */ public static Value parseValue(String nTriplesValue, ValueFactory valueFactory) throws IllegalArgumentException { if (nTriplesValue.startsWith("<")) { return parseURI(nTriplesValue, valueFactory); } else if (nTriplesValue.startsWith("_:")) { return parseBNode(nTriplesValue, valueFactory); } else if (nTriplesValue.startsWith("\"")) { return parseLiteral(nTriplesValue, valueFactory); } else { throw new IllegalArgumentException("Not a legal N-Triples value: " + nTriplesValue); } }
/** * Parser method returning Statement from a single HBase Result Cell * @param c HBase Result Cell * @return Statements */ public static Statement parseStatement(Cell c) { ByteBuffer bb = ByteBuffer.wrap(c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()); byte[] sb = new byte[bb.getInt()]; byte[] pb = new byte[bb.getInt()]; byte[] ob = new byte[bb.getInt()]; bb.get(sb); bb.get(pb); bb.get(ob); byte[] cb = new byte[bb.remaining()]; bb.get(cb); ValueFactory vf = SimpleValueFactory.getInstance(); return vf.createStatement(NTriplesUtil.parseResource(new String(sb, UTF8), vf), NTriplesUtil.parseURI(new String(pb, UTF8), vf), NTriplesUtil.parseValue(new String(ob,UTF8), vf), cb.length == 0 ? null : NTriplesUtil.parseResource(new String(cb,UTF8), vf)); }
@Override protected void setup(Context context) throws IOException, InterruptedException { SimpleValueFactory vf = SimpleValueFactory.getInstance(); Configuration conf = context.getConfiguration(); String s = conf.get(SUBJECT); if (s!= null) { subj = NTriplesUtil.parseResource(s, vf); } String p = conf.get(PREDICATE); if (p!= null) { pred = NTriplesUtil.parseURI(p, vf); } String o = conf.get(OBJECT); if (o!= null) { obj = NTriplesUtil.parseValue(o, vf); } String cs[] = conf.getStrings(CONTEXTS); if (cs != null) { ctx = new ArrayList<>(); for (String c : cs) { if ("NONE".equals(c)) { ctx.add(null); } else { ctx.add(NTriplesUtil.parseResource(c, vf)); } } } }
IRI dtURI = parseURI(datatype, valueFactory); return valueFactory.createLiteral(label, dtURI);
IRI dtURI = parseURI(datatype, valueFactory); return valueFactory.createLiteral(label, dtURI);
/** * Registers a cartesian geospatial subtype. * * @param stripWidth the strip width in some units * @param xmin the minimum x range * @param ymin the minimum y range * @param xmax the maximum x range * @param ymax the maximum y range * @return URI the datatype encoding of this subtype * @throws RepositoryException if there is an error during the request */ public IRI registerCartesianType(float stripWidth, float xmin, float xmax, float ymin, float ymax) throws RepositoryException { String nTriplesURI = prepareHttpRepoClient().registerCartesianType(stripWidth, xmin, xmax, ymin, ymax); return NTriplesUtil.parseURI(nTriplesURI, getValueFactory()); }
/** * Registers a spherical geospatial subtype. * * @param stripWidth the strip width in some units * @param unit the distance unit <code>stripWidth</code> is specified in * @param latmin the minimum latitude range * @param lonmin the minimum longitude range * @param latmax the maximum latitude range * @param lonmax the maximum longitude range * @return URI the datatype encoding of this subtype * @throws RepositoryException if there is an error during the request */ public IRI registerSphericalType(float stripWidth, String unit, float latmin, float lonmin, float latmax, float lonmax) throws RepositoryException { String nTriplesURI = prepareHttpRepoClient().registerSphericalType(stripWidth, unit, latmin, lonmin, latmax, lonmax); return NTriplesUtil.parseURI(nTriplesURI, getValueFactory()); }
uris = new IRI[uri_strs.length]; for (int i = 0; i < uri_strs.length; i++) { uris[i] = NTriplesUtil.parseURI(uri_strs[i], this);
byte[] cb = new byte[bb.remaining()]; bb.get(cb); graph = NTriplesUtil.parseURI(new String(cb,UTF8), ssf);