org.apache.jena.rdf.model.AnonId Java Examples
The following examples show how to use
org.apache.jena.rdf.model.AnonId.
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: StrUtils.java From SDA with BSD 2-Clause "Simplified" License | 6 votes |
/** * 무명의 이름 * @param id * @return String */ protected static String anonName(AnonId id) { String name = "_:A"; final String sid = id.toString(); for (int i = 0; i < sid.length(); i++) { final char c = sid.charAt(i); if (c == 'X') { name = name + "XX"; } else if (Character.isLetterOrDigit(c)) { name = name + c; } else { name = name + "X" + Integer.toHexString(c) + "X"; } } return name; }
Example #2
Source File: StrUtils.java From SDA with BSD 2-Clause "Simplified" License | 6 votes |
/** * 무명의 이름 * @param id * @return String */ protected static String anonName(AnonId id) { String name = "_:A"; final String sid = id.toString(); for (int i = 0; i < sid.length(); i++) { final char c = sid.charAt(i); if (c == 'X') { name = name + "XX"; } else if (Character.isLetterOrDigit(c)) { name = name + c; } else { name = name + "X" + Integer.toHexString(c) + "X"; } } return name; }
Example #3
Source File: SimpleLicensingInfo.java From tools with Apache License 2.0 | 6 votes |
@Override public Resource findDuplicateResource(IModelContainer modelContainer, String uri) throws InvalidSPDXAnalysisException { Property idProperty = modelContainer.getModel().createProperty(SpdxRdfConstants.SPDX_NAMESPACE, SpdxRdfConstants.PROP_LICENSE_ID); Property typeProperty = modelContainer.getModel().getProperty(SpdxRdfConstants.RDF_NAMESPACE, SpdxRdfConstants.RDF_PROP_TYPE); Triple m = Triple.createMatch(null, idProperty.asNode(), null); ExtendedIterator<Triple> tripleIter = modelContainer.getModel().getGraph().find(m); while (tripleIter.hasNext()) { Triple t = tripleIter.next(); if (t.getObject().toString(false).equals(this.licenseId)) { Triple typeMatch = Triple.createMatch(t.getSubject(), typeProperty.asNode(), getType(modelContainer.getModel()).asNode()); ExtendedIterator<Triple> typeTripleIter = modelContainer.getModel().getGraph().find(typeMatch); if (typeTripleIter.hasNext()) { // found it if (t.getSubject().isURI()) { return modelContainer.getModel().createResource(t.getSubject().getURI()); } else if (t.getSubject().isBlank()) { return modelContainer.getModel().createResource(new AnonId(t.getSubject().getBlankNodeId())); } } } } return null; }
Example #4
Source File: String2Node.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public String2Node(String type, String value, short datatype) { if(value.equals("NULL")){ node = null; } else if (value.startsWith(Constants.PREFIX_BLANK_NODE)) { AnonId id = new AnonId(value.substring(Constants.PREFIX_BLANK_NODE.length())); node = ModelFactory.createDefaultModel().createResource(id); } else if (type.equals(Constants.NAME_COLUMN_SUBJECT)) { node = ResourceFactory.createResource(value); } else if (type.equals(Constants.NAME_COLUMN_PREDICATE)) { node = ResourceFactory.createProperty(value); } else if (type.equals(Constants.NAME_COLUMN_OBJECT)) { assignLiteral(value, datatype); } }
Example #5
Source File: String2Node.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public String2Node(String type, String value) { if(value.equals("NULL")){ node = null; } else if (value.startsWith(Constants.PREFIX_BLANK_NODE)) { AnonId id = new AnonId(value.substring(Constants.PREFIX_BLANK_NODE.length())); node = ModelFactory.createDefaultModel().createResource(id); } else if (type.equals(Constants.NAME_COLUMN_SUBJECT)) { node = ResourceFactory.createResource(value); } else if (type.equals(Constants.NAME_COLUMN_PREDICATE)) { node = ResourceFactory.createProperty(value); } else if (type.equals(Constants.NAME_COLUMN_OBJECT)) { assert (false); // mdb change code call other ctor } }
Example #6
Source File: StrUtils.java From SDA with BSD 2-Clause "Simplified" License | 5 votes |
protected static String anonName(AnonId id) { String name = "_:A"; final String sid = id.toString(); for (int i = 0; i < sid.length(); i++) { final char c = sid.charAt(i); if (c == 'X') { name = name + "XX"; } else if (Character.isLetterOrDigit(c)) { name = name + c; } else { name = name + "X" + Integer.toHexString(c) + "X"; } } return name; }
Example #7
Source File: StrUtils.java From SDA with BSD 2-Clause "Simplified" License | 5 votes |
protected static String anonName(AnonId id) { String name = "_:A"; final String sid = id.toString(); for (int i = 0; i < sid.length(); i++) { final char c = sid.charAt(i); if (c == 'X') { name = name + "XX"; } else if (Character.isLetterOrDigit(c)) { name = name + c; } else { name = name + "X" + Integer.toHexString(c) + "X"; } } return name; }
Example #8
Source File: RdfParserHelper.java From tools with Apache License 2.0 | 5 votes |
/** * Convert a node to a resource * @param cmodel * @param cnode * @return * @throws InvalidSPDXAnalysisException */ public static Resource convertToResource(Model cmodel, Node cnode) throws InvalidSPDXAnalysisException { if (cnode.isBlank()) { return cmodel.createResource(new AnonId(cnode.getBlankNodeId())); } else if (cnode.isURI()) { return cmodel.createResource(cnode.getURI()); } else { throw(new InvalidSPDXAnalysisException("Can not create a resource from a literal")); } }
Example #9
Source File: SPDXDocument.java From tools with Apache License 2.0 | 5 votes |
private Resource getResource(Node node) throws InvalidSPDXAnalysisException { Resource s; if (node.isURI()) { s = model.createResource(node.getURI()); } else if (node.isBlank()) { s = model.createResource(new AnonId(node.getBlankNodeId())); } else { throw(new InvalidSPDXAnalysisException("Node can not be a literal")); } return s; }
Example #10
Source File: RdfModelObject.java From tools with Apache License 2.0 | 5 votes |
/** * Create an RDF Model Object based on an existing Node * @param modelContainer Container containing the RDF Model * @param node Node describing this object * @throws InvalidSPDXAnalysisException */ public RdfModelObject(IModelContainer modelContainer, Node node) throws InvalidSPDXAnalysisException { this.modelContainer = modelContainer; this.model = modelContainer.getModel(); this.node = node; this.refreshOnGet = modelContainer.addCheckNodeObject(node, this); if (node.isBlank()) { resource = model.createResource(new AnonId(node.getBlankNodeId())); } else if (node.isURI()) { resource = model.createResource(node.getURI()); } else { throw(new InvalidSPDXAnalysisException("Can not have an model node as a literal")); } }
Example #11
Source File: SpdxDocumentContainer.java From tools with Apache License 2.0 | 5 votes |
private Resource getResource(Node node) throws InvalidSPDXAnalysisException { Resource s; if (node.isURI()) { s = model.createResource(node.getURI()); } else if (node.isBlank()) { s = model.createResource(new AnonId(node.getBlankNodeId())); } else { throw(new InvalidSPDXAnalysisException("Node can not be a literal")); } return s; }
Example #12
Source File: JenaUtil.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public static RDFNode fromAtom(Model m, Object o, BasicUniverse u, Instance t2) { if (o instanceof Pair<?,?>) { return fromLiteral(m, (Pair<String,Object>) o, u, t2); } else if (o.toString().startsWith("_:")) { return m.createResource(new AnonId(o.toString())); } else { return m.createResource(o.toString()); } }