View Javadoc

1   /*
2    * Copyright 2004 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.ancientprogramming.fixedformat4j.annotation;
17  
18  import com.ancientprogramming.fixedformat4j.format.FixedFormatter;
19  import com.ancientprogramming.fixedformat4j.format.impl.ByTypeFormatter;
20  
21  import java.lang.annotation.Target;
22  import java.lang.annotation.ElementType;
23  import java.lang.annotation.Retention;
24  import java.lang.annotation.RetentionPolicy;
25  
26  /**
27   * This annotation descibes how a setter/getter pairs should be formatted by the fixedFormatManager.
28   *
29   * @author Jacob von Eyben - http://www.ancientprogramming.com
30   * @since 1.0.0
31   */
32  @Retention(RetentionPolicy.RUNTIME)
33  @Target({ElementType.METHOD})
34  public @interface Field {
35  
36    /**
37     * A one based offset to insert data at in a record.
38     * @return the offset as an int
39     */
40    int offset();
41  
42    /**
43     * The length of the formatted field
44     * @return the length as an int
45     */
46    int length();
47  
48    /**
49     * @return The direction of the padding. Defaults to {@link Align#RIGHT}.
50     */
51    Align align() default Align.LEFT;
52  
53    /**
54     * The character to pad with if the length is longer than the formatted data
55     * @return the padding character
56     */
57    char paddingChar() default ' ';
58  
59    Class<? extends FixedFormatter> formatter() default ByTypeFormatter.class;
60  
61  }