private FixedDataSchema parseFixed( NamedTypeDeclarationContext context, FixedDeclarationContext fixed) throws ParseException { Name name = toName(fixed.name); FixedDataSchema schema = new FixedDataSchema(name); bindNameToSchema(name, schema); schema.setSize(fixed.size, errorMessageBuilder()); setProperties(context, schema); return schema; }
@Override public ByteString getFixed(String fieldName, FixedDataSchema schema) { final byte[] bytes = new byte[schema.getSize()]; _random.nextBytes(bytes); return ByteString.copy(bytes); }
private void writeFixed(FixedDataSchema schema) throws IOException { writeDoc(schema.getDoc()); writeProperties(schema.getProperties()); write("fixed "); write(toTypeIdentifier(schema)); write(" "); write(String.valueOf(schema.getSize())); }
private ClassTemplateSpec generateFixed(FixedDataSchema schema) { final FixedTemplateSpec fixedClass = new FixedTemplateSpec(schema); fixedClass.setNamespace(schema.getNamespace()); fixedClass.setClassName(schema.getName()); fixedClass.setModifiers(ModifierSpec.PUBLIC); registerClassTemplateSpec(schema, fixedClass); return fixedClass; }
/** * Set the size of the fixed size data. * * @param size of the fixed size data. * @param errorMessageBuilder to append error message to. * @return false if size is negative. */ public boolean setSize(int size, StringBuilder errorMessageBuilder) { boolean ok = true; if (size < 0) { errorMessageBuilder.append(size).append(" is negative, size must not be negative.\n"); ok = false; } else { _size = size; } if (ok == false) { setHasError(); } return ok; }
private FixedDataSchema parseFixed( NamedTypeDeclarationContext context, FixedDeclarationContext fixed) throws ParseException { Name name = toName(fixed.name); FixedDataSchema schema = new FixedDataSchema(name); bindNameToSchema(name, schema); schema.setSize(fixed.size, errorMessageBuilder()); setProperties(context, schema); return schema; }
private void checkFixed(FixedDataSchema older, FixedDataSchema newer) { checkName(older, newer); _path.addLast(DataSchemaConstants.SIZE_KEY); int olderSize = older.getSize(); int newerSize = newer.getSize(); if (olderSize != newerSize) { appendMessage(CompatibilityMessage.Impact.BREAKS_NEW_AND_OLD_READERS, "fixed size changed from %d to %d", olderSize, newerSize); } _path.removeLast(); }
case FIXED: Integer size = getInteger(map, SIZE_KEY, true); FixedDataSchema fixedSchema = new FixedDataSchema(name); schema = namedSchema = fixedSchema; bindNameToSchema(name, aliasNames, fixedSchema); fixedSchema.setSize(size, startCalleeMessageBuilder()); appendCalleeMessage(size); break;
if (data.length() != schema.getSize()) throw new TemplateOutputCastException("Fixed size is " + schema.getSize() + ", string length is " + data.length()); if (bytes.length() != schema.getSize()) throw new TemplateOutputCastException("Fixed size is " + schema.getSize() + ", ByteString length is " + bytes.length());
int size = schema.getSize(); if (clazz == String.class)
break; case FIXED: _builder.writeIntField(SIZE_KEY, ((FixedDataSchema) schema).getSize()); break; case RECORD: