protected void initializeTimeStamps() { Field timeStampField = fieldMap.get(TIMESTAMP); startTimestamp = Long.valueOf(timeStampField.getMinValue()); endTimestamp = Long.valueOf(timeStampField.getMaxValue()); stepValue = Long.valueOf(timeStampField.getStepValue()); populateTimestampsForSplits(); }
protected String getValueWithPadding(String value, Field field) { int paddingLength = field.getFixedLength() - value.length(); StringBuilder valueWithPadding = new StringBuilder(); for (int i = 0; i < paddingLength; i++) { valueWithPadding.append(field.getPadding()); } return valueWithPadding.append(value).toString(); }
protected void createMasterQuotes() { populateFieldMap(); masterQuotes = new HashMap<String, List<PriceSet>>(); Field symbolField = fieldMap.get(SYMBOL); String[] symbols = symbolField.getRange().split(","); for (String symbolName : symbols) { masterQuotes.put(symbolName, createPriceSets()); } }
@Override public String randomValueAsString(Field<TYPE> field) { TYPE randomValue = randomValue(field); String stringValue = randomValue.toString(); if (field.getPadding() != null) { long maxLength = field.getMaxLength() != 0 ? field.getMaxLength() : field.getFixedLength(); stringValue = paddedRandomValue(field.getPadding(), randomValue, maxLength); } return stringValue; }
private void populateFieldMap() { fieldMap = new HashMap<String, Field>(); for (Field field : schema.getFields()) { fieldMap.put(field.getName(), field); } }
@Override public TYPE randomValue(Field<TYPE> field) { TYPE value = null; if (field.getConstantValue() != null) { value = valueFromString(field.getConstantValue()); return value; } if (field.getRange() != null) { List<TYPE> values = (List<TYPE>) Arrays.asList(field.getRange().split(",")); value = randomValueFromRange(values); return value; } // If min max values are specified they take precedence over length if (field.getMinValue() != null && field.getMaxValue() != null) { TYPE minValue = valueFromString(field.getMinValue()); TYPE maxValue = valueFromString(field.getMaxValue()); value = randomValueFromRange(minValue, maxValue); return value; } long minLength = field.getMinLength() != 0 ? field.getMinLength() : field.getFixedLength(); long maxLength = field.getMaxLength() != 0 ? field.getMaxLength() : field.getFixedLength(); if (field.getPrefix() != null) { value = randomValueWithPrefix(minLength, maxLength, field.getPrefix()); return value; } if (field.getSuffix() != null) { value = randomValueWithSuffix(minLength, maxLength, field.getSuffix()); return value; } value = randomValue(minLength, maxLength); return value; }