/** * Returns true if there is a statement for the given property. This is a * convenience method for accessing the data that can be obtained via * {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return true if a statement for this property exists */ default boolean hasStatement(PropertyIdValue propertyIdValue) { return findStatementGroup(propertyIdValue) != null; }
/** * Returns the unique {@link TimeValue} for the given property, or null if * there are zero or many such values given in statements for this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link TimeValue} or null */ default TimeValue findStatementTimeValue(PropertyIdValue propertyIdValue) { Value value = findStatementValue(propertyIdValue); return value instanceof TimeValue ? (TimeValue) value : null; }
/** * Returns an iterator that provides access to all statements, without * considering the statement groups. The order of statements is preserved. * * @return iterator over all statements */ default Iterator<Statement> getAllStatements() { return new NestedIterator<>(getStatementGroups()); }
entityStatistics.count++; if (statementDocument.getStatementGroups().size() > 0) { this.countPropertyEntities++; .findStatementGroup("P31"); if (instanceOfStatements != null) { for (StatementGroup sg : statementDocument.getStatementGroups()) { entityStatistics.countStatements += sg.size(); PropertyRecord propertyRecord = getPropertyRecord(sg.getProperty());
/** * Helper method that finds the first value of a time-valued property (if * any), and extracts an integer year. It checks if the value has sufficient * precision to extract an exact year. * * @param document * the document to extract the data from * @param propertyId * the string id of the property to look for * @return the year, or Interger.MIN_VALUE if none was found */ private int getYearIfAny(StatementDocument document, String propertyId) { TimeValue date = document.findStatementTimeValue(propertyId); if (date != null && date.getPrecision() >= TimeValue.PREC_YEAR) { return (int) date.getYear(); } else { return Integer.MIN_VALUE; } }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link Value} or null */ default Value findStatementValue(PropertyIdValue propertyIdValue) { Statement statement = findStatement(propertyIdValue); return (statement != null) ? statement.getValue() : null; }
protected static String toStringForStatementDocument(StatementDocument o) { StringBuilder sb = new StringBuilder(); sb.append("\n===Statements===\n"); for (StatementGroup sg : o.getStatementGroups()) { sb.append(toString(sg)); } sb.append("\n===End of statements===\n"); return sb.toString(); }
/** * Helper method that finds the first value of a time-valued property (if * any), and extracts an integer year. It checks if the value has sufficient * precision to extract an exact year. * * @param document * the document to extract the data from * @param propertyId * string id of the property to look for * @return the year, or Interger.MIN_VALUE if none was found */ private int getYearIfAny(StatementDocument document, String propertyId) { TimeValue date = document.findStatementTimeValue(propertyId); if (date != null && date.getPrecision() >= TimeValue.PREC_YEAR) { return (int) date.getYear(); } else { return Integer.MIN_VALUE; } }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link Value} or null */ default Value findStatementValue(PropertyIdValue propertyIdValue) { Statement statement = findStatement(propertyIdValue); return (statement != null) ? statement.getValue() : null; }
/** * Returns an iterator that provides access to all statements, without * considering the statement groups. The order of statements is preserved. * * @return iterator over all statements */ default Iterator<Statement> getAllStatements() { return new NestedIterator<>(getStatementGroups()); }
/** * Returns true if there is a statement for the given property. This is a * convenience method for accessing the data that can be obtained via * {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return true if a statement for this property exists */ default boolean hasStatement(PropertyIdValue propertyIdValue) { return findStatementGroup(propertyIdValue) != null; }
/** * Returns the unique {@link StringValue} for the given property, or null if * there are zero or many such values given in statements for this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link StringValue} or null */ default StringValue findStatementStringValue(PropertyIdValue propertyIdValue) { Value value = findStatementValue(propertyIdValue); return value instanceof StringValue ? (StringValue) value : null; }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. Only the * string id of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return {@link Value} or null */ default Value findStatementValue(String propertyId) { Statement statement = findStatement(propertyId); return (statement != null) ? statement.getValue() : null; }
protected static String toStringForStatementDocument(StatementDocument o) { StringBuilder sb = new StringBuilder(); sb.append("\n===Statements===\n"); for (StatementGroup sg : o.getStatementGroups()) { sb.append(toString(sg)); } sb.append("\n===End of statements===\n"); return sb.toString(); }
/** * Returns true if there is a statement for the given property. Only the * string id of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return true if a statement for this property exists */ default boolean hasStatement(String propertyId) { return findStatementGroup(propertyId) != null; }
/** * Returns the unique {@link ItemIdValue} for the given property, or null if * there are zero or many such values given in statements for this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link ItemIdValue} or null */ default ItemIdValue findStatementItemIdValue(PropertyIdValue propertyIdValue) { Value value = findStatementValue(propertyIdValue); return value instanceof ItemIdValue ? (ItemIdValue) value : null; }
/** * Returns the unique {@link Value} for the given property, or null if there * are zero or many values given in statements for this property. Only the * string id of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return {@link Value} or null */ default Value findStatementValue(String propertyId) { Statement statement = findStatement(propertyId); return (statement != null) ? statement.getValue() : null; }
/** * Returns the {@link StatementGroup} for the given property, or null if * there are no statements for this property. This is a convenience method * for accessing the data that can be obtained via * {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link StatementGroup} or null */ default StatementGroup findStatementGroup(PropertyIdValue propertyIdValue) { for (StatementGroup sg : getStatementGroups()) { if (propertyIdValue.equals(sg.getProperty())) { return sg; } } return null; }
/** * Returns true if there is a statement for the given property. Only the * string id of the property is compared, not the site id. This is useful in * situations where all data is known to come from a single site. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyId * the property to search for * @return true if a statement for this property exists */ default boolean hasStatement(String propertyId) { return findStatementGroup(propertyId) != null; }
/** * Returns the unique {@link MonolingualTextValue} for the given property, * or null if there are zero or many such values given in statements for * this property. * <p> * This is a convenience method for accessing the data that can be obtained * via {@link #getStatementGroups()}. * * @param propertyIdValue * the property to search for * @return {@link MonolingualTextValue} or null */ default MonolingualTextValue findStatementMonolingualTextValue( PropertyIdValue propertyIdValue) { Value value = findStatementValue(propertyIdValue); return value instanceof MonolingualTextValue ? (MonolingualTextValue) value : null; }