Java 类org.apache.avro.generic.GenericData.StringType 实例源码

项目:kaa    文件:JavaSdkGenerator.java   
/**
 * Generate schema class.
 *
 * @param schema        the schema
 * @param uniqueSchemas the unique schemas
 * @return the list
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static List<JavaDynamicBean> generateSchemaSources(
    Schema schema, Map<String, Schema> uniqueSchemas) throws IOException {
  SpecificCompiler compiler = new SpecificCompiler(schema);
  compiler.setStringType(StringType.String);
  compiler.setFieldVisibility(FieldVisibility.PRIVATE);

  File tmpdir = new File(System.getProperty("java.io.tmpdir"));
  long value = RANDOM.nextLong();
  if (value == Long.MIN_VALUE) {
    // corner case
    value = 0;
  } else {
    value = Math.abs(value);
  }
  File tmpOutputDir = new File(tmpdir, "tmp-gen-" + Long.toString(value));
  tmpOutputDir.mkdirs();

  compiler.compileToDestination(null, tmpOutputDir);

  List<JavaDynamicBean> sources = getJavaSources(tmpOutputDir, uniqueSchemas);

  tmpOutputDir.delete();

  return sources;
}
项目:gradle-avro-plugin    文件:GenerateAvroJavaTask.java   
@TaskAction
protected void process() {
    parsedStringType = Enums.parseCaseInsensitive(OPTION_STRING_TYPE, StringType.values(), getStringType());
    parsedFieldVisibility =
        Enums.parseCaseInsensitive(OPTION_FIELD_VISIBILITY, FieldVisibility.values(), getFieldVisibility());
    getLogger().debug("Using outputCharacterEncoding {}", getOutputCharacterEncoding());
    getLogger().debug("Using stringType {}", parsedStringType.name());
    getLogger().debug("Using fieldVisibility {}", parsedFieldVisibility.name());
    getLogger().debug("Using templateDirectory '{}'", getTemplateDirectory());
    getLogger().debug("Using createSetters {}", isCreateSetters());
    getLogger().debug("Using enableDecimalLogicalType {}", isEnableDecimalLogicalType());
    getLogger().debug("Using validateDefaults {}", isValidateDefaults());
    getLogger().info("Found {} files", getInputs().getSourceFiles().getFiles().size());
    failOnUnsupportedFiles();
    processFiles();
}
项目:legstar.avro    文件:Cob2AvroGenerator.java   
/**
 * Given an Avro schema produce java specific classes.
 * 
 * @param avroSchemaFile the Avro schema file (used by avro for timestamp
 *            checking)
 * @param avroSchemaSource the Avro schema source
 * @param javaTargetFolder the target folder for java classes
 * @throws IOException if compilation fails
 */
private void avroCompile(String avroSchemaSource, File avroSchemaFile,
        File javaTargetFolder) throws IOException {

    log.debug("Avro compiler started for: {}", avroSchemaFile);

    Schema.Parser parser = new Schema.Parser();
    Schema schema = parser.parse(avroSchemaSource);
    SpecificCompiler compiler = new CustomSpecificCompiler(schema);
    compiler.setStringType(StringType.CharSequence);
    compiler.compileToDestination(avroSchemaFile, javaTargetFolder);

    log.debug("Avro compiler ended for: {}", avroSchemaFile);
}
项目:gradle-avro-plugin    文件:GenerateAvroJavaTask.java   
public void setStringType(GenericData.StringType stringType) {
    setStringType(stringType.name());
}