@Override public boolean accept(FieldType fieldtype) { return fieldtype.getValueType().getDeepestValueType().getBaseName().equals("LINK"); } };
@Override public List<String> format(List<IndexValue> indexValues, LRepository repository) throws InterruptedException { List<String> result = new ArrayList<String>(); for (IndexValue indexValue : indexValues) { ValueType valueType = indexValue.fieldType.getValueType(); if (valueType.getBaseName().equals("LIST")) { // The values of the first list-level are supplied as individual IndexValues valueType = valueType.getNestedValueType(); } if (!valueType.getName().equals("STRING")) { throw new RuntimeException(this.getClass().getSimpleName() + " only supports string values, but got: " + valueType.getName()); } processPath((String)indexValue.value, result); } return result; }
@Override @SuppressWarnings("unchecked") public List<Object> read(DataInput dataInput) throws RepositoryException, InterruptedException { int nrOfValues = dataInput.readInt(); List<Object> result = new ArrayList<Object>(nrOfValues); for (int i = 0 ; i < nrOfValues; i++) { result.add(valueType.read(dataInput)); } return result; }
public static List flatList(Object value, ValueType type) { if (type.getBaseName().equals("LIST")) { if (type.getNestedValueType().getBaseName() != "LIST") { return (List)value; } else { List result = Lists.newArrayList(); for (Object nValue: (List)value) { result.addAll(flatList(nValue, type.getNestedValueType())); } return result; } } else { return Collections.singletonList(value); } }
public static String toString(Object value, ValueType valueType) { if (value == null) { throw new NullPointerException(); } if (!valueType.getType().isAssignableFrom(value.getClass())) { throw new IllegalArgumentException("Value is not of the type indicated by the value type. Value type" + " class: " + valueType.getType().getName() + ", value class: " + value.getClass().getName()); } StringConverter converter = CONVERTERS.get(valueType.getBaseName()); if (converter == null) { throw new IllegalArgumentException("Value type not supported: " + valueType.getBaseName()); } return converter.toString(value); }
if (!valueType.getType().isAssignableFrom(fieldValue.getClass())) { throw new RepositoryException(String.format("Incorrect type of value provided for field %s. " + "Expected instance of %s but got %s.", fieldType.getName(), valueType.getType().getName(), fieldValue.getClass().getName())); valueType.write(fieldValue, dataOutput, new IdentityRecordStack(parentRecord)); } catch (InterruptedException e) { throw e; throw new RuntimeException("Field metadata is currently not supported for versioned-mutable fields."); if (fieldType.getValueType().getDeepestValueType().getBaseName().equals("BLOB")) { throw new RuntimeException("Field metadata is currently not supported for BLOB fields.");
protected ValueFormatter getFormatter(ValueType valueType) { ValueFormatter formatter = FORMATTERS.get(valueType.getBaseName()); return formatter == null ? ALL_FORMATTER : formatter; }
Object value = record.getField(fieldName); ValueType valueType = fieldType.getValueType(); if (!valueType.getDeepestValueType().getBaseName().equals("BLOB")) { throw new BlobNotFoundException("Blob could not be retrieved from '" + record.getId() + "', '" + fieldName + "' at index: " + Ints.join("/", indexes)); int index = indexes[i]; try { if (valueType.getBaseName().equals("LIST")) { value = ((List<Object>) value).get(index); valueType = valueType.getNestedValueType(); continue; if (valueType.getBaseName().equals("PATH")) { value = ((HierarchyPath)value).getElements()[index]; valueType = valueType.getNestedValueType(); continue; if (!valueType.getBaseName().equals("BLOB")) { throw new BlobNotFoundException("Blob could not be retrieved from '" + record.getId() + "', '" + fieldName + "' at index: " + Ints.join("/", indexes));
@Override public String toString() { return "FieldTypeImpl [" + "id=" + id + ", valueType=" + (valueType != null ? valueType.getName() : "null") + ", name=" + name + ", scope=" + scope + ']'; } }
for (Entry<Long, byte[]> cell : cellsSet) { if (valueType.getDeepestValueType() instanceof BlobValueType) { Object blobValue = null; if (fieldType.getScope() == Scope.NON_VERSIONED) { byte[] value = cell.getValue(); if (!isDeleteMarker(value)) { blobValue = valueType.read(EncodingUtil.stripPrefix(value));
@Override public ValueType getDeepestValueType() { return valueType.getDeepestValueType(); }
Comparator comparator = valueType.getComparator(); + "that does not support comparison: " + valueType.getName());
private Set<BlobReference> getReferencedBlobs(FieldTypeImpl fieldType, Object value) throws BlobException { HashSet<BlobReference> referencedBlobs = new HashSet<BlobReference>(); ValueType valueType = fieldType.getValueType(); if ((valueType.getDeepestValueType() instanceof BlobValueType) && !isDeleteMarker(value)) { Set<Object> values = valueType.getValues(value); for (Object object : values) { referencedBlobs.add(new BlobReference((Blob) object, null, fieldType)); } } return referencedBlobs; }
@Override public String format(Object path, ValueType valueType, FormatContext formatCtx) throws InterruptedException { StringBuilder builder = new StringBuilder(); for (Object value : (HierarchyPath)path) { String formatted = formatCtx.format(value, valueType.getNestedValueType(), formatCtx); builder.append("/"); builder.append(formatted); } return returnBuilderResult(builder); } }
@Override public void write(Object value, DataOutput dataOutput, IdentityRecordStack parentRecords) throws RepositoryException, InterruptedException { List<Object> values = ((List<Object>) value); dataOutput.writeInt(values.size()); for (Object element : values) { valueType.write(element, dataOutput, parentRecords); } }
return false; } else if (!valueType.equals(other.valueType)) { return false;
private void addField(FieldType type, Object oldValue, Object newValue, RecordEvent.IndexRecordFilterData idxSel) throws RepositoryException, InterruptedException { if (oldValue == null && newValue == null) { return; } if (oldValue != null) { oldValue = type.getValueType().toBytes(oldValue, new IdentityRecordStack()); } if (newValue != null) { newValue = type.getValueType().toBytes(newValue, new IdentityRecordStack()); } idxSel.addChangedField(type.getId(), (byte[])oldValue, (byte[])newValue); }
/** * * @throws IllegalArgumentException if the value cannot be parsed or if the value type * is not supported */ public static Object fromString(String value, ValueType valueType, IdGenerator idGenerator) { StringConverter converter = CONVERTERS.get(valueType.getBaseName()); if (converter == null) { throw new IllegalArgumentException("Value type not supported: " + valueType.getBaseName()); } return converter.fromString(value, idGenerator); }