/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(Statement o) { StringBuilder sb = new StringBuilder(); sb.append("[ID ").append(o.getStatementId()).append("] "); sb.append(o.getSubject()).append(": "); sb.append(o.getMainSnak().toString()).append("\n"); for (SnakGroup s : o.getQualifiers()) { sb.append(toString(s)); } if (o.getRank() != StatementRank.NORMAL) { sb.append(" Rank: ").append(o.getRank()).append("\n"); } for (Reference r : o.getReferences()) { sb.append(toString(r)); } return sb.toString(); }
/** * Returns a human-readable string representation of the given object. * * @see java.lang.Object#toString() * @param o * the object to represent as string * @return a string representation of the object */ public static String toString(Statement o) { StringBuilder sb = new StringBuilder(); sb.append("[ID ").append(o.getStatementId()).append("] "); sb.append(o.getSubject()).append(": "); sb.append(o.getMainSnak().toString()).append("\n"); for (SnakGroup s : o.getQualifiers()) { sb.append(toString(s)); } if (o.getRank() != StatementRank.NORMAL) { sb.append(" Rank: ").append(o.getRank()).append("\n"); } for (Reference r : o.getReferences()) { sb.append(toString(r)); } return sb.toString(); }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(Statement o) { int result; result = o.getSubject().hashCode(); result = prime * result + o.getMainSnak().hashCode(); result = prime * result + o.getQualifiers().hashCode(); result = prime * result + o.getReferences().hashCode(); result = prime * result + o.getRank().hashCode(); result = prime * result + o.getStatementId().hashCode(); return result; }
/** * Returns a hash code for the given object. * * @see java.lang.Object#hashCode() * @param o * the object to create a hash for * @return the hash code of the object */ public static int hashCode(Statement o) { int result; result = o.getSubject().hashCode(); result = prime * result + o.getMainSnak().hashCode(); result = prime * result + o.getQualifiers().hashCode(); result = prime * result + o.getReferences().hashCode(); result = prime * result + o.getRank().hashCode(); result = prime * result + o.getStatementId().hashCode(); return result; }
/** * Returns true if the parameters are two {@link Statement} objects with * exactly the same data. It does not matter if they are different * implementations of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsStatement(Statement o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof Statement)) { return false; } Statement other = (Statement) o2; return o1.getSubject().equals(other.getSubject()) && o1.getMainSnak().equals(other.getMainSnak()) && o1.getQualifiers().equals(other.getQualifiers()) && o1.getReferences().equals(other.getReferences()) && o1.getRank() == other.getRank() && o1.getStatementId().equals(other.getStatementId()); }
/** * Returns true if the parameters are two {@link Statement} objects with * exactly the same data. It does not matter if they are different * implementations of the interface as long as their content is the same. * * @param o1 * the first object to compare * @param o2 * the second object to compare * @return true if both objects are equal */ public static boolean equalsStatement(Statement o1, Object o2) { if (o2 == null) { return false; } if (o2 == o1) { return true; } if (!(o2 instanceof Statement)) { return false; } Statement other = (Statement) o2; return o1.getSubject().equals(other.getSubject()) && o1.getMainSnak().equals(other.getMainSnak()) && o1.getQualifiers().equals(other.getQualifiers()) && o1.getReferences().equals(other.getReferences()) && o1.getRank() == other.getRank() && o1.getStatementId().equals(other.getStatementId()); }
void writeStatement(Statement statement) throws RDFHandlerException { String statementUri = Vocabulary.getStatementUri(statement); Resource statementResource = this.rdfWriter.getUri(statementUri); this.rdfWriter.writeTripleValueObject(statementResource, RdfWriter.RDF_TYPE, RdfWriter.WB_STATEMENT); writeClaim(statementResource, statement.getClaim()); writeReferences(statementResource, statement.getReferences()); // TODO What about the RANK? }
void writeStatement(Statement statement) throws RDFHandlerException { String statementUri = Vocabulary.getStatementUri(statement); Resource statementResource = this.rdfWriter.getUri(statementUri); this.rdfWriter.writeTripleValueObject(statementResource, RdfWriter.RDF_TYPE, RdfWriter.WB_STATEMENT); writeClaim(statementResource, statement.getClaim()); writeReferences(statementResource, statement.getReferences()); writeStatementRankTriple(statementResource, statement.getRank()); }
statement1.getReferences(), statement2.getReferences());
statement1.getReferences(), statement2.getReferences());
.getSnaks().size()); for (Reference r : s.getReferences()) { usageStatistics.countReferencedStatements++; for (SnakGroup snakGroup : r.getSnakGroups()) {
/** * Copies a {@link Statement}. * * @param object * object to copy * @return copied object */ public Statement copy(Statement object) { return dataObjectFactory.getStatement( (EntityIdValue) visit(object.getSubject()), copy(object.getMainSnak()), copy(object.getQualifiers()), copyReferences(object.getReferences()), object.getRank(), object.getStatementId()); }
.withValue(exactValue).withId(s.getStatementId()) .withQualifiers(s.getQualifiers()) .withReferences(s.getReferences()) .withRank(s.getRank()).build(); updateStatements.add(exactStatement);
/** * Copies a {@link Statement}. * * @param object * object to copy * @return copied object */ public Statement copy(Statement object) { return dataObjectFactory.getStatement( (EntityIdValue) visit(object.getSubject()), copy(object.getMainSnak()), copy(object.getQualifiers()), copyReferences(object.getReferences()), object.getRank(), object.getStatementId()); }
.withValue(exactValue).withId(s.getStatementId()) .withQualifiers(s.getClaim().getQualifiers()) .withReferences(s.getReferences()) .withRank(s.getRank()).build(); updateStatements.add(exactStatement);
for (Reference r : s.getReferences()) { for (SnakGroup snakGroup : r.getSnakGroups()) { countPropertyReference(snakGroup.getProperty(),
for (Reference r : s.getReferences()) { for (SnakGroup snakGroup : r.getSnakGroups()) { countPropertyReference(snakGroup.getProperty(), snakGroup.size());
/** * Count the statements and property uses of an item or property document. * * @param usageStatistics * statistics object to store counters in * @param statementDocument * document to count the statements of */ protected void countStatements(UsageStatistics usageStatistics, StatementDocument statementDocument) { // Count Statement data: for (StatementGroup sg : statementDocument.getStatementGroups()) { // Count Statements: usageStatistics.countStatements += sg.size(); // Count uses of properties in Statements: countPropertyMain(usageStatistics, sg.getProperty(), sg.size()); for (Statement s : sg) { for (SnakGroup q : s.getQualifiers()) { countPropertyQualifier(usageStatistics, q.getProperty(), q.size()); } for (Reference r : s.getReferences()) { usageStatistics.countReferencedStatements++; for (SnakGroup snakGroup : r.getSnakGroups()) { countPropertyReference(usageStatistics, snakGroup.getProperty(), snakGroup.size()); } } } } }
.withId(statementToModify.getStatementId()) .withValue(Datamodel.makeStringValue("Updated string value 1")) .withReferences(statementToModify.getReferences()).build();
.withId(statementToModify.getStatementId()) .withValue(Datamodel.makeStringValue("Updated string value 1")) .withReferences(statementToModify.getReferences()).build();