/** * Determines if the specified record is compatible with this record type. This method returns * {@code true} if the specified {@code record} argument is non-null and the following condition * holds: * * <p> * * <ul> * <li><code> * {@linkplain #getMembers()}.{@linkplain Set#containsAll containsAll}(record.{@linkplain * Record#getAttributes() getAttributes()}.{@linkplain Map#keySet keySet()})</code> * <li>Any other implementation-specific conditions. * </ul> * * @todo Replace {@code equals} by {@code containsAll}. */ public boolean isInstance(final Record record) { return getMembers().equals(record.getAttributes().keySet()); } }
/** * Creates a new record initialized to a shallow copy of the given record. * The members contained in the given record are <strong>not</strong> recursively copied. * * @param record the record to copy (can not be null). * * @since 0.8 */ @SuppressWarnings("SuspiciousSystemArraycopy") public DefaultRecord(final Record record) { this(record.getRecordType()); if (record instanceof DefaultRecord) { final Object source = ((DefaultRecord) record).values; System.arraycopy(source, 0, values, 0, Array.getLength(source)); } else { for (final Map.Entry<MemberName,Integer> entry : definition.memberIndices().entrySet()) { final MemberName name = entry.getKey(); final Object value = record.locate(name); if (value != null) { final int index = entry.getValue(); final Class<?> valueClass = definition.getValueClass(index); if (valueClass != null && !valueClass.isInstance(value)) { throw new ClassCastException(Errors.format(Errors.Keys.IllegalPropertyValueClass_3, name, valueClass, value.getClass())); } Array.set(values, index, value); } } } }
List<Future<Boolean>> tasks = new ArrayList<>(); for (Record record: file.getRecords()) { Executor executorForRecord = executors.get(record.getRecordType()); tasks.add(executor.submit(new RecordProcessor(record))); }
/** * Creates a new record initialized to a shallow copy of the given record. * The members contained in the given record are <strong>not</strong> recursively copied. * * @param record the record to copy (can not be null). * * @since 0.8 */ @SuppressWarnings("SuspiciousSystemArraycopy") public DefaultRecord(final Record record) { this(record.getRecordType()); if (record instanceof DefaultRecord) { final Object source = ((DefaultRecord) record).values; System.arraycopy(source, 0, values, 0, Array.getLength(source)); } else { for (final Map.Entry<MemberName,Integer> entry : definition.memberIndices().entrySet()) { final MemberName name = entry.getKey(); final Object value = record.locate(name); if (value != null) { final int index = entry.getValue(); final Class<?> valueClass = definition.getValueClass(index); if (valueClass != null && !valueClass.isInstance(value)) { throw new ClassCastException(Errors.format(Errors.Keys.IllegalPropertyValueClass_3, name, valueClass, value.getClass())); } Array.set(values, index, value); } } } }
/** * Return the value type for reporting a data quality result. * * <div class="section">Default value</div> * If no type has been set but all {@linkplain #getValues() values} are of the same type, * then this method defaults to that type. Otherwise this method returns {@code null}. * * @return value type for reporting a data quality result, or {@code null}. */ @Override @XmlElement(name = "valueRecordType") public RecordType getValueType() { RecordType type = valueType; if (type == null && values != null) { for (final Record value : values) { if (value != null) { final RecordType t = value.getRecordType(); if (t == null) { return null; } else if (type == null) { type = t; } else if (type != t) { return null; } } } } return type; }
if (unit != null && SI.METRE.isCompatible(unit)) { for (final Record record : records) { for (final Object value : record.getAttributes().values()) { if (value instanceof Number) { double v = ((Number) value).doubleValue();
/** * Return the value type for reporting a data quality result. * * <div class="section">Default value</div> * If no type has been set but all {@linkplain #getValues() values} are of the same type, * then this method defaults to that type. Otherwise this method returns {@code null}. * * @return value type for reporting a data quality result, or {@code null}. */ @Override @XmlElement(name = "valueType") public RecordType getValueType() { RecordType type = valueType; if (type == null && values != null) { for (final Record value : values) { if (value != null) { final RecordType t = value.getRecordType(); if (t == null) { return null; } else if (type == null) { type = t; } else if (type != t) { return null; } } } } return type; }
/** * Determines if the specified record is compatible with this record type. This method returns * {@code true} if the specified {@code record} argument is non-null and the following condition * holds: * * {@preformat java * getMembers().containsAll(record.getAttributes().keySet()) * } * @param record The record to test for compatibility. * @return {@code true} if the given record is compatible with this {@code RecordType}. */ @Override public boolean isInstance(final Record record) { return memberTypes.keySet().containsAll(record.getAttributes().keySet()); }
for (Record record : slide.getSlideRecord().getChildRecords()) { if (record instanceof UnknownRecordPlaceholder && record.getRecordType() == RecordTypes.SSSlideInfoAtom.typeID) { UnknownRecordPlaceholder urp = (UnknownRecordPlaceholder)record;
/** * Check if this record can work with us. * <p> * The following should hold true: * <ul> * <li>getMembers().equals( record.getAttributes().keySet() ) * <li>you can add more conditions in a subclass * </p> * I kind of wish that the record just had all the members present * but what can you do (perhaps the spec has a reason). * @return true of record attributes line up with getMembers */ public boolean isInstance( Record record ) { return getMembers().equals( record.getAttributes().keySet() ); } /**
/** * Determines if the specified record is compatible with this record type. This method returns * {@code true} if the specified {@code record} argument is non-null and the following condition * holds: * <p> * <ul> * <li><code>{@linkplain #getMembers()}.{@linkplain Set#containsAll containsAll}(record.{@linkplain * Record#getAttributes() getAttributes()}.{@linkplain Map#keySet keySet()})</code></li> * <li>Any other implementation-specific conditions. * </ul> * * @todo Replace {@code equals} by {@code containsAll}. */ public boolean isInstance(final Record record) { return getMembers().equals(record.getAttributes().keySet()); } }
/** * Determines if the given record is compatible with this record type. This method returns {@code true} * if the given {@code record} argument is non-null and the following condition holds: * * {@preformat java * Set<MemberName> attributeNames = record.getAttributes().keySet(); * boolean isInstance = getMembers().containsAll(attributeNames); * } * * <div class="note"><b>Implementation note:</b> * We do not require that {@code record.getRecordType() == this} in order to allow record * "sub-types" to define additional fields, in a way similar to Java sub-classing.</div> * * @param record the record to test for compatibility. * @return {@code true} if the given record is compatible with this {@code RecordType}. */ @Override public boolean isInstance(final Record record) { return (record != null) && getMembers().containsAll(record.getAttributes().keySet()); }
/** * Determines if the given record is compatible with this record type. This method returns {@code true} * if the given {@code record} argument is non-null and the following condition holds: * * {@preformat java * Set<MemberName> attributeNames = record.getAttributes().keySet(); * boolean isInstance = getMembers().containsAll(attributeNames); * } * * <div class="note"><b>Implementation note:</b> * We do not require that {@code record.getRecordType() == this} in order to allow record * "sub-types" to define additional fields, in a way similar to Java sub-classing.</div> * * @param record the record to test for compatibility. * @return {@code true} if the given record is compatible with this {@code RecordType}. */ @Override public boolean isInstance(final Record record) { return (record != null) && getMembers().containsAll(record.getAttributes().keySet()); }
text = (locale != Locale.ROOT) ? ((Currency) value).getDisplayName(locale) : value.toString(); } else if (value instanceof Record) { formatCollection(((Record) value).getAttributes().values(), recursive); return; } else if (value instanceof Iterable<?>) {
final Unit<Length> unitOfLength = unit.asType(Length.class); for (final Record record : records) { for (final Object value : record.getAttributes().values()) { if (value instanceof Number) { double v = ((Number) value).doubleValue();
text = (locale != Locale.ROOT) ? ((Currency) value).getDisplayName(locale) : value.toString(); } else if (value instanceof Record) { formatCollection(((Record) value).getAttributes().values(), recursive); return; } else if (value instanceof Iterable<?>) {
final Unit<Length> unitOfLength = unit.asType(Length.class); for (final Record record : records) { for (final Object value : record.getAttributes().values()) { if (value instanceof Number) { double v = ((Number) value).doubleValue();