/** * Copies a {@link Snak}. * * @param snak * object to copy * @return copied object */ public Snak copySnak(Snak snak) { return snak.accept(this); }
@Override public PropertyIdValue getProperty() { return this.snaks.get(0).getPropertyId(); }
@Override public Value getValue() { return mainSnak.getValue(); }
while (snaks.hasNext()) { Snak snak = snaks.next(); if ("P1535".equals(snak.getPropertyId().getId()) && ItemGadgetAuthorityControl.equals(snak .getValue())) { pr.urlPattern = urlPattern; foundGacUrl = true;
@Override public PropertyIdValue getProperty() { return this.snaks.get(0).getPropertyId(); }
/** * Copies a {@link Snak}. * * @param snak * object to copy * @return copied object */ public Snak copySnak(Snak snak) { return snak.accept(this); }
@Override public Value getValue() { return mainSnak.getValue(); }
/** * Constructor. * * @param snaks * a non-empty list of snaks that use the same property */ public SnakGroupImpl(List<Snak> snaks) { if (snaks == null || snaks.isEmpty()) { throw new IllegalArgumentException("A non-empty list of Snaks must be provided to create a SnakGroup"); } PropertyIdValue property = snaks.get(0).getPropertyId(); for (Snak s : snaks) { if (!property.equals(s.getPropertyId())) { throw new IllegalArgumentException( "All snaks in a snak group must use the same property"); } } this.snaks = Collections. unmodifiableList(snaks); }
/** * Writes the given snak for the given subject. The context defines if the * snak is used as a main snak, qualifier, or in a reference. Some data * might be buffered instead of being written immediately. The method * {@link #writeAuxiliaryTriples()} needs to be called to serialize this * additional data later on. * * @param snak * the snake to write * @param subject * the resource that should be used as a subject of the serialied * triples * @param propertyContext * the context in which the snak is used */ public void writeSnak(Snak snak, Resource subject, PropertyContext propertyContext) { setSnakContext(subject, propertyContext); snak.accept(this); }
Value value = s.getMainSnak().getValue(); if (value instanceof StringValue) { imageFile = ((StringValue) value).getString();
@Override public PropertyIdValue getProperty() { return statements.get(0).getMainSnak().getPropertyId(); }
/** * Writes the given snak for the given subject. The context defines if the * snak is used as a main snak, qualifier, or in a reference. Some data * might be buffered instead of being written immediately. The method * {@link #writeAuxiliaryTriples()} needs to be called to serialize this * additional data later on. * * @param snak * the snake to write * @param subject * the resource that should be used as a subject of the serialied * triples * @param propertyContext * the context in which the snak is used */ public void writeSnak(Snak snak, Resource subject, PropertyContext propertyContext) { setSnakContext(subject, propertyContext); snak.accept(this); }
/** * Constructor. * * @param snaks * a non-empty list of snaks that use the same property */ public SnakGroupImpl(List<Snak> snaks) { if (snaks == null || snaks.isEmpty()) { throw new IllegalArgumentException("A non-empty list of Snaks must be provided to create a SnakGroup"); } PropertyIdValue property = snaks.get(0).getPropertyId(); for (Snak s : snaks) { if (!property.equals(s.getPropertyId())) { throw new IllegalArgumentException( "All snaks in a snak group must use the same property"); } } this.snaks = Collections. unmodifiableList(snaks); }
void writeClaim(Resource claimResource, Claim claim) { this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.VALUE); claim.getMainSnak().accept(this.snakRdfConverter); this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.QUALIFIER); for (SnakGroup snakGroup : claim.getQualifiers()) { for (Snak snak : snakGroup.getSnaks()) { snak.accept(this.snakRdfConverter); } } }
@Override public PropertyIdValue getProperty() { return statements.get(0).getMainSnak().getPropertyId(); }
void writeClaim(Resource claimResource, Claim claim) { // write main snak this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.VALUE); claim.getMainSnak().accept(this.snakRdfConverter); this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.VALUE_SIMPLE); claim.getMainSnak().accept(this.snakRdfConverter); // write qualifier this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.QUALIFIER); for (SnakGroup snakGroup : claim.getQualifiers()) { for (Snak snak : snakGroup) { snak.accept(this.snakRdfConverter); } } this.snakRdfConverter.setSnakContext(claimResource, PropertyContext.QUALIFIER_SIMPLE); for (SnakGroup snakGroup : claim.getQualifiers()) { for (Snak snak : snakGroup) { snak.accept(this.snakRdfConverter); } } }
/** * Adds a qualifier {@link Snak} to the constructed statement. * * @param qualifier * the qualifier to add * @return builder object to continue construction */ public StatementBuilder withQualifier(Snak qualifier) { getQualifierList(qualifier.getPropertyId()).add(qualifier); return getThis(); }
void writeReference(Reference reference, Resource resource) throws RDFHandlerException { this.rdfWriter.writeTripleValueObject(resource, RdfWriter.RDF_TYPE, RdfWriter.WB_REFERENCE); for (SnakGroup snakGroup : reference.getSnakGroups()) { this.snakRdfConverter.setSnakContext(resource, PropertyContext.REFERENCE); for (Snak snak : snakGroup) { snak.accept(this.snakRdfConverter); } } } }
/** * Adds a qualifier {@link Snak} to the constructed statement. * * @param qualifier * the qualifier to add * @return builder object to continue construction */ public StatementBuilder withQualifier(Snak qualifier) { getQualifierList(qualifier.getPropertyId()).add(qualifier); return getThis(); }
void writeSimpleStatements(Resource subject, StatementDocument statementDocument) { for (StatementGroup statementGroup : statementDocument .getStatementGroups()) { for (Statement statement : statementGroup) { if (statement.getQualifiers().size() == 0) { this.snakRdfConverter.setSnakContext(subject, PropertyContext.DIRECT); statement.getMainSnak() .accept(this.snakRdfConverter); } } } }