diff --git a/src/main/java/io/kaitai/struct/annotations/Field.java b/src/main/java/io/kaitai/struct/annotations/Field.java new file mode 100644 index 0000000..7a09c6b --- /dev/null +++ b/src/main/java/io/kaitai/struct/annotations/Field.java @@ -0,0 +1,60 @@ +/** + * Copyright 2015-2020 Kaitai Project: MIT license + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package io.kaitai.struct.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation, that applied to fields, getters or setters that represents field + * from {@code seq} language element. + * + * @author Mingun + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.METHOD}) +public @interface Field { + /** + * Original identifier ({@code id} key) from {@code ksy} file. + * + * @return Identifier, that can differ from field name, if it clash with + * Java reserved words. Empty string, if field was unnamed + */ + String id(); + /** + * Index of field in sequence of fields in the type + * + * @return 0-based index of field in {@code seq} language element + */ + int index(); + /** + * Documentation string, that attached to the field in {@code doc} language element. + * + * @return Documentation string for field. If documentation is missed, returns empty string + */ + String doc(); +} diff --git a/src/main/java/io/kaitai/struct/annotations/Generated.java b/src/main/java/io/kaitai/struct/annotations/Generated.java new file mode 100644 index 0000000..4b203d8 --- /dev/null +++ b/src/main/java/io/kaitai/struct/annotations/Generated.java @@ -0,0 +1,101 @@ +/** + * Copyright 2015-2020 Kaitai Project: MIT license + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package io.kaitai.struct.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation, that applied to Kaitai-generated classes. Visualizers can use that + * annotation to find classes, that contains generated stuff, that should be showed + * in visualization. + * + * @author Mingun + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Generated { + /** + * Original identifier ({@code id} key) from {@code ksy} file. + * + * @return Identifier, that can differ from class name, if it clash with + * Java reserved words. Can not be empty + */ + String id(); + /** + * Version of compiler, that generated this class. + * + * @return Version string in semver format + */ + String version(); + /** + * Class compiled with support of position tracking. That means, that every class + * has following public fields (in that version of generator): + *
Type | Field | Description |
---|---|---|
{@code Map | {@code _attrStart} | + *Start offset in root stream, where {@link Field field} or + * {@link Instance instance} with specified name begins. + * Used only for fields/instances, that is not repeated | + *
{@code Map | {@code _attrEnd} | + *Start offset in root stream, where {@link Field field} or + * {@link Instance instance} with specified name ends (exclusive). + * Used only for fields/instances, that is not repeated | + *
{@code Map | {@code _arrStart} | + *List with start offset in root stream, where each array element of repeated + * {@link Field field} or {@link Instance instance} with specified name begins. + * Used only for fields/instances, that is repeated | + *
{@code Map | {@code _arrEnd} | + *List with end offset (exclusive) in root stream, where each array element of repeated + * {@link Field field} or {@link Instance instance} with specified name ends. + * Used only for fields/instances, that is repeated | + *