|
| 1 | +/** |
| 2 | + * Copyright 2015-2020 Kaitai Project: MIT license |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | + * a copy of this software and associated documentation files (the |
| 6 | + * "Software"), to deal in the Software without restriction, including |
| 7 | + * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | + * distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | + * permit persons to whom the Software is furnished to do so, subject to |
| 10 | + * the following conditions: |
| 11 | + * |
| 12 | + * The above copyright notice and this permission notice shall be |
| 13 | + * included in all copies or substantial portions of the Software. |
| 14 | + * |
| 15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 | + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 19 | + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 20 | + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 21 | + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | + */ |
| 23 | +package io.kaitai.struct.annotations; |
| 24 | + |
| 25 | +import java.lang.annotation.Documented; |
| 26 | +import java.lang.annotation.ElementType; |
| 27 | +import java.lang.annotation.Retention; |
| 28 | +import java.lang.annotation.RetentionPolicy; |
| 29 | +import java.lang.annotation.Target; |
| 30 | + |
| 31 | +/** |
| 32 | + * Annotation, that applied to Kaitai-generated classes. Visualizers can use that |
| 33 | + * annotation to find classes, that contains generated stuff, that should be showed |
| 34 | + * in visualization. |
| 35 | + * |
| 36 | + * @since 0.9 |
| 37 | + */ |
| 38 | +@Documented |
| 39 | +@Retention(RetentionPolicy.RUNTIME) |
| 40 | +@Target(ElementType.TYPE) |
| 41 | +public @interface Generated { |
| 42 | + /** |
| 43 | + * Original identifier ({@code id} key) from {@code ksy} file. |
| 44 | + * |
| 45 | + * @return Identifier, that can differ from class name, if it clash with |
| 46 | + * Java reserved words. Can not be empty |
| 47 | + */ |
| 48 | + String id(); |
| 49 | + /** |
| 50 | + * Version of compiler, that generated this class. |
| 51 | + * |
| 52 | + * @return Version string in <a href="https://semver.org/">semver</a> format |
| 53 | + */ |
| 54 | + String version(); |
| 55 | + /** |
| 56 | + * Class compiled with support of position tracking. That means, that every class |
| 57 | + * has following public fields (in that version of generator): |
| 58 | + * <table> |
| 59 | + * <tr><th>Type</th><th>Field</th><th>Description</th></tr> |
| 60 | + * <tr><td>{@code Map<String, Integer>}</td><td>{@code _attrStart}</td> |
| 61 | + * <td>Start offset in the root stream, where {@link SeqItem an attribute} or |
| 62 | + * {@link Instance an instance} with specified name begins. |
| 63 | + * Used only for attributes/instances, that is not repeated</td> |
| 64 | + * </tr> |
| 65 | + * <tr><td>{@code Map<String, Integer>}</td><td>{@code _attrEnd}</td> |
| 66 | + * <td>Start offset in the root stream, where {@link SeqItem an attribute} or |
| 67 | + * {@link Instance an instance} with specified name ends (exclusive). |
| 68 | + * Used only for attributes/instances, that is not repeated</td> |
| 69 | + * </tr> |
| 70 | + * <tr><td>{@code Map<String, ? extends List<Integer>>}</td><td>{@code _arrStart}</td> |
| 71 | + * <td>List with start offset in the root stream, where each array element of |
| 72 | + * repeated {@link SeqItem attribute} or {@link Instance instance} with |
| 73 | + * specified name begins. Used only for attributes/instances, that is repeated</td> |
| 74 | + * </tr> |
| 75 | + * <tr><td>{@code Map<String, ? extends List<Integer>>}</td><td>{@code _arrEnd}</td> |
| 76 | + * <td>List with end offset (exclusive) in the root stream, where each array |
| 77 | + * element of repeated {@link SeqItem attribute} or {@link Instance instance} |
| 78 | + * with specified name ends. Used only for attributes/instances, that is repeated</td> |
| 79 | + * </tr> |
| 80 | + * </table> |
| 81 | + * |
| 82 | + * @return {@code true}, if position tracking is enabled and {@code false} otherwise |
| 83 | + */ |
| 84 | + boolean posInfo(); |
| 85 | + /** |
| 86 | + * Determines, if instantiation of user classes (related to user-types, defined |
| 87 | + * in {@code ksy} file) automatically read its content from the stream, or that must |
| 88 | + * be performed manually by calling generated {@code _read()}, {@code _readBE()} |
| 89 | + * or {@code _readLE()} method. |
| 90 | + * |
| 91 | + * @return {@code true}, if generated {@code _read()} method invoked automatically |
| 92 | + * by class constructors and {@code false}, if it must be called explicitly |
| 93 | + */ |
| 94 | + boolean autoRead(); |
| 95 | + /** |
| 96 | + * Documentation string attached to the type definition, specified in {@code doc} |
| 97 | + * KSY element. |
| 98 | + * |
| 99 | + * @return Documentation string for a type. If documentation is missed, returns empty string |
| 100 | + */ |
| 101 | + String doc(); |
| 102 | +} |
0 commit comments