Class SbeTool

java.lang.Object
uk.co.real_logic.sbe.SbeTool

public class SbeTool extends Object
A tool for running the SBE parser, validator, and code generator.

Usage:

     $ java -jar sbe.jar <filename.xml>
     $ java -Doption=value -jar sbe.jar <filename.xml>
     $ java -Doption=value -jar sbe.jar <filename.sbeir>
 

System Properties:

  • sbe.validation.xsd: Use XSD to validate or not.
  • sbe.validation.stop.on.error: Should the parser stop on first error encountered? Defaults to false.
  • sbe.validation.warnings.fatal: Are warnings in parsing considered fatal? Defaults to false.
  • sbe.validation.suppress.output: Should the parser suppress output during validation? Defaults to false.
  • sbe.generate.stubs: Generate stubs or not. Defaults to true.
  • sbe.target.language: Target language for code generation, defaults to Java.
  • sbe.generate.ir: Generate IR or not. Defaults to false.
  • sbe.output.dir: Target directory for code generation, defaults to current directory.
  • sbe.java.generate.interfaces: Generate interface hierarchy or not. Defaults to false.
  • sbe.java.encoding.buffer.type: Type of the Java interface for the encoding buffer to wrap.
  • sbe.java.decoding.buffer.type: Type of the Java interface for the decoding buffer to wrap.
  • sbe.target.namespace: Namespace for the generated code to override schema package.
  • sbe.cpp.namespaces.collapse: Namespace for the generated code to override schema package.
  • sbe.java.generate.group-order.annotation: Should the GroupOrder annotation be added to generated stubs.
  • sbe.csharp.generate.namespace.dir: Should a directory be created for the namespace under the output directory? Defaults to true
  • sbe.keyword.append.token: Token to be appended to keywords.
  • sbe.decode.unknown.enum.values: Support unknown decoded enum values. Defaults to false.
  • sbe.xinclude.aware: Is XInclude supported for the schema. Defaults to false.
  • sbe.type.package.override: Is package attribute for types element supported (only for JAVA). Defaults to false.
  • Field Details

    • JAVA_INTERFACE_PACKAGE

      public static final String JAVA_INTERFACE_PACKAGE
      Package in which the generated Java interfaces will be placed.
      See Also:
    • JAVA_DEFAULT_ENCODING_BUFFER_TYPE

      public static final String JAVA_DEFAULT_ENCODING_BUFFER_TYPE
      Default class to use as the buffer mutable implementation in generated code.
    • JAVA_DEFAULT_DECODING_BUFFER_TYPE

      public static final String JAVA_DEFAULT_DECODING_BUFFER_TYPE
      Default class to use as the buffer read only implementation in generated code.
    • VALIDATION_STOP_ON_ERROR

      public static final String VALIDATION_STOP_ON_ERROR
      Boolean system property to control throwing exceptions on all errors.
      See Also:
    • VALIDATION_WARNINGS_FATAL

      public static final String VALIDATION_WARNINGS_FATAL
      Boolean system property to control whether to consider warnings fatal and treat them as errors.
      See Also:
    • VALIDATION_XSD

      public static final String VALIDATION_XSD
      System property to hold XSD to validate message specification against.
      See Also:
    • VALIDATION_SUPPRESS_OUTPUT

      public static final String VALIDATION_SUPPRESS_OUTPUT
      Boolean system property to control suppressing output on all errors and warnings.
      See Also:
    • GENERATE_STUBS

      public static final String GENERATE_STUBS
      Boolean system property to turn on or off generation of stubs. Defaults to true.
      See Also:
    • XINCLUDE_AWARE

      public static final String XINCLUDE_AWARE
      Boolean system property to control is XInclude is supported. Defaults to false.
      See Also:
    • TYPES_PACKAGE_OVERRIDE

      public static final String TYPES_PACKAGE_OVERRIDE
      Boolean system property to control the support of package names in <types> elements. Part of SBE v2-rc3. Defaults to false.
      See Also:
    • TARGET_LANGUAGE

      public static final String TARGET_LANGUAGE
      Target language for generated code.
      See Also:
    • GENERATE_IR

      public static final String GENERATE_IR
      Boolean system property to turn on or off generation of IR. Defaults to false.
      See Also:
    • OUTPUT_DIR

      public static final String OUTPUT_DIR
      Output directory for generated code.
      See Also:
    • TARGET_NAMESPACE

      public static final String TARGET_NAMESPACE
      String system property of the namespace for generated code.
      See Also:
    • CPP_NAMESPACES_COLLAPSE

      public static final String CPP_NAMESPACES_COLLAPSE
      Boolean system property to toggle collapsing of nested namespaces in generated C++ stubs. Defaults to false.
      See Also:
    • RUST_CRATE_VERSION

      public static final String RUST_CRATE_VERSION
      Version of the Rust crate to generate.
      See Also:
    • RUST_DEFAULT_CRATE_VERSION

      public static final String RUST_DEFAULT_CRATE_VERSION
      The default version of the Rust crate to generate, when not specified via the system property.
      See Also:
    • JAVA_GENERATE_INTERFACES

      public static final String JAVA_GENERATE_INTERFACES
      Boolean system property to turn on or off generation of the interface hierarchy. Defaults to false.
      See Also:
    • JAVA_ENCODING_BUFFER_TYPE

      public static final String JAVA_ENCODING_BUFFER_TYPE
      Specifies the name of the Java mutable buffer to wrap.
      See Also:
    • JAVA_DECODING_BUFFER_TYPE

      public static final String JAVA_DECODING_BUFFER_TYPE
      Specifies the name of the Java read only buffer to wrap.
      See Also:
    • JAVA_GROUP_ORDER_ANNOTATION

      public static final String JAVA_GROUP_ORDER_ANNOTATION
      Should the GroupOrder annotation be added to generated stubs.
      See Also:
    • CSHARP_GENERATE_NAMESPACE_DIR

      public static final String CSHARP_GENERATE_NAMESPACE_DIR
      Boolean system property to turn on or off generation of namespace directories during csharp code generation. Defaults to true
      See Also:
    • KEYWORD_APPEND_TOKEN

      public static final String KEYWORD_APPEND_TOKEN
      Specifies token that should be appended to keywords to avoid compilation errors.

      If none is supplied then use of keywords results in an error during schema parsing. The underscore character is a good example of a token to use.

      See Also:
    • DECODE_UNKNOWN_ENUM_VALUES

      public static final String DECODE_UNKNOWN_ENUM_VALUES
      Should unknown enum values be decoded to support extension. Defaults to false.

      If an unknown enum value is decoded then a language specific SBE_UNKNOWN enum value will be returned rather than throwing an error.

      See Also:
    • CPP_GENERATE_DTOS

      public static final String CPP_GENERATE_DTOS
      Should generate C++ DTOs. Defaults to false.
      See Also:
    • JAVA_GENERATE_DTOS

      public static final String JAVA_GENERATE_DTOS
      Should generate Java DTOs. Defaults to false.
      See Also:
    • SCHEMA_TRANSFORM_VERSION

      public static final String SCHEMA_TRANSFORM_VERSION
      Configuration option used to manage sinceVersion based transformations. When set, parsed schemas will be transformed to discard messages and types higher than the specified version. This can be useful when needing to generate older versions of a schema to do version compatibility testing.

      This field can contain a list of ordered pairs in the form: ((<schema id> | '*') ':' <schema id>)(',' ((<schema id> | '*') ':' <schema id>))* . E.g. 123:5,*:6 which means transform schema with id = 123 to version 5, all others to version 6.

      See Also:
    • GENERATE_PRECEDENCE_CHECKS

      public static final String GENERATE_PRECEDENCE_CHECKS
      Whether to generate field precedence checks. For example, whether to check that repeating groups are encoded in schema order.
      See Also:
    • PRECEDENCE_CHECKS_FLAG_NAME

      public static final String PRECEDENCE_CHECKS_FLAG_NAME
      The name of the symbol or macro that enables access order checks when building generated C# or C++ code.
      See Also:
    • JAVA_PRECEDENCE_CHECKS_PROPERTY_NAME

      public static final String JAVA_PRECEDENCE_CHECKS_PROPERTY_NAME
      The name of the system property that enables access order checks at runtime in generated Java code.
      See Also:
  • Constructor Details

    • SbeTool

      public SbeTool()
  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Main entry point for the SBE Tool.
      Parameters:
      args - command line arguments. A single filename is expected.
      Throws:
      Exception - if an error occurs during process of the message schema.
    • validateAgainstSchema

      public static void validateAgainstSchema(String sbeSchemaFilename, String xsdFilename) throws Exception
      Validate the SBE Schema against the XSD.
      Parameters:
      sbeSchemaFilename - to be validated.
      xsdFilename - XSD against which to validate.
      Throws:
      Exception - if an error occurs while validating.
    • parseSchema

      public static MessageSchema parseSchema(String sbeSchemaFilename) throws Exception
      Parse the message schema specification.
      Parameters:
      sbeSchemaFilename - file containing the SBE specification to be parsed.
      Returns:
      the parsed MessageSchema for the specification found in the file.
      Throws:
      Exception - if an error occurs when parsing the specification.
    • generate

      public static void generate(Ir ir, String outputDirName, String targetLanguage) throws Exception
      Generate SBE encoding and decoding stubs for a target language.
      Parameters:
      ir - for the parsed specification.
      outputDirName - directory into which code will be generated.
      targetLanguage - for the generated code.
      Throws:
      Exception - if an error occurs while generating the code.