public Field createField(Object value) { if (docValues && !indexed) { return createDocValueField(name, value); } else { if (javaType == String.class) return new Field(name, (String) value, fieldType); if (javaType == Integer.class) return new IntField(name, (Integer) value, fieldType); if (javaType == Long.class) return new LongField(name, (Long) value, fieldType); if (javaType == Double.class) return new DoubleField(name, (Double) value, fieldType); if (javaType == Float.class) return new FloatField(name, (Float) value, fieldType); if (javaType == Boolean.class) return new Field(name, getBoolValue(value), fieldType); if (javaType == Date.class) return new LongField(name, ((Date) value).getTime(), fieldType); if (javaType == Byte[].class) return new Field(name, (byte[]) value, fieldType); } throw Validate.notAllowed(""); }
public void setValue(Field field, Object value) { if (javaType == String.class) { field.setStringValue((String) value); } else if (javaType == Double.class) { field.setDoubleValue((Double) value); } else if (javaType == Float.class) { field.setFloatValue((Float) value); } else if (javaType == Integer.class) { field.setIntValue((Integer) value); } else if (javaType == Long.class) { field.setLongValue((Long) value); } else if (javaType == Boolean.class) { field.setStringValue(getBoolValue(value)); } else if (javaType == Date.class) { field.setLongValue(((Date) value).getTime()); } else if (javaType == Byte[].class) { field.setBytesValue((byte[]) value); } throw Validate.notAllowed(""); }
public Field createDocValueField(String fieldName, Object value) { if (javaType == String.class) { if (multiValue) { return new SortedSetDocValuesField(fieldName, new BytesRef(value.toString())); } else { return new SortedDocValuesField(fieldName, new BytesRef(value.toString())); } } if (javaType == Long.class) { if (multiValue == false) { return new SortedNumericDocValuesField(fieldName, (Long) value); } } if (javaType == Date.class) { if (multiValue == false) { return new SortedNumericDocValuesField(fieldName, ((Date) value).getTime()); } } throw Validate.notAllowed(""); }
private IndexedField getWrite() { if (frozen) { Validate.notAllowed("Object is frozen"); } return this; }