| 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.format; | |
| 17 | ||
| 18 | import com.ancientprogramming.fixedformat4j.annotation.Align; | |
| 19 | import com.ancientprogramming.fixedformat4j.format.data.FixedFormatBooleanData; | |
| 20 | import com.ancientprogramming.fixedformat4j.format.data.FixedFormatPatternData; | |
| 21 | import com.ancientprogramming.fixedformat4j.format.data.FixedFormatDecimalData; | |
| 22 | import com.ancientprogramming.fixedformat4j.format.data.FixedFormatNumberData; | |
| 23 | ||
| 24 | /** | |
| 25 | * Contains instructions on how to export and load fixed formatted data. | |
| 26 | * | |
| 27 | * @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> | |
| 28 | * @since 1.0.0 | |
| 29 | */ | |
| 30 | public class FormatInstructions { | |
| 31 | ||
| 32 | private int length; | |
| 33 | private Align alignment; | |
| 34 | private char paddingChar; | |
| 35 | private FixedFormatPatternData fixedFormatPatternData; | |
| 36 | private FixedFormatBooleanData fixedFormatBooleanData; | |
| 37 | private FixedFormatNumberData fixedFormatNumberData; | |
| 38 | private FixedFormatDecimalData fixedFormatDecimalData; | |
| 39 | ||
| 40 | /** | |
| 41 | * Creates a fully-populated set of format instructions. | |
| 42 | * | |
| 43 | * @param length the fixed width of the field in characters | |
| 44 | * @param alignment the alignment strategy used to pad and strip the field | |
| 45 | * @param paddingChar the character used for padding | |
| 46 | * @param fixedFormatPatternData date/time pattern configuration, or {@code null} if unused | |
| 47 | * @param fixedFormatBooleanData boolean value configuration, or {@code null} if unused | |
| 48 | * @param fixedFormatNumberData number sign configuration, or {@code null} if unused | |
| 49 | * @param fixedFormatDecimalData decimal precision configuration, or {@code null} if unused | |
| 50 | */ | |
| 51 | public FormatInstructions(int length, Align alignment, char paddingChar, FixedFormatPatternData fixedFormatPatternData, FixedFormatBooleanData fixedFormatBooleanData, FixedFormatNumberData fixedFormatNumberData, FixedFormatDecimalData fixedFormatDecimalData) { | |
| 52 | this.length = length; | |
| 53 | this.alignment = alignment; | |
| 54 | this.paddingChar = paddingChar; | |
| 55 | this.fixedFormatPatternData = fixedFormatPatternData; | |
| 56 | this.fixedFormatBooleanData = fixedFormatBooleanData; | |
| 57 | this.fixedFormatNumberData = fixedFormatNumberData; | |
| 58 | this.fixedFormatDecimalData = fixedFormatDecimalData; | |
| 59 | } | |
| 60 | ||
| 61 | /** | |
| 62 | * Returns the fixed character width of the field. | |
| 63 | * | |
| 64 | * @return the field length in characters | |
| 65 | */ | |
| 66 | public int getLength() { | |
| 67 |
1
1. getLength : replaced int return with 0 for com/ancientprogramming/fixedformat4j/format/FormatInstructions::getLength → KILLED |
return length; |
| 68 | } | |
| 69 | ||
| 70 | /** | |
| 71 | * Returns the alignment strategy used to pad and strip the field value. | |
| 72 | * | |
| 73 | * @return the {@link Align} constant for this field | |
| 74 | */ | |
| 75 | public Align getAlignment() { | |
| 76 |
1
1. getAlignment : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FormatInstructions::getAlignment → KILLED |
return alignment; |
| 77 | } | |
| 78 | ||
| 79 | /** | |
| 80 | * Returns the character used to pad the field to its full length. | |
| 81 | * | |
| 82 | * @return the padding character | |
| 83 | */ | |
| 84 | public char getPaddingChar() { | |
| 85 |
1
1. getPaddingChar : replaced char return with 0 for com/ancientprogramming/fixedformat4j/format/FormatInstructions::getPaddingChar → KILLED |
return paddingChar; |
| 86 | } | |
| 87 | ||
| 88 | /** | |
| 89 | * Returns the date/time pattern configuration for this field. | |
| 90 | * | |
| 91 | * @return the {@link FixedFormatPatternData}, or {@code null} if no pattern annotation is present | |
| 92 | */ | |
| 93 | public FixedFormatPatternData getFixedFormatPatternData() { | |
| 94 |
1
1. getFixedFormatPatternData : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FormatInstructions::getFixedFormatPatternData → KILLED |
return fixedFormatPatternData; |
| 95 | } | |
| 96 | ||
| 97 | /** | |
| 98 | * Returns the boolean value configuration for this field. | |
| 99 | * | |
| 100 | * @return the {@link FixedFormatBooleanData}, or {@code null} if no boolean annotation is present | |
| 101 | */ | |
| 102 | public FixedFormatBooleanData getFixedFormatBooleanData() { | |
| 103 |
1
1. getFixedFormatBooleanData : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FormatInstructions::getFixedFormatBooleanData → KILLED |
return fixedFormatBooleanData; |
| 104 | } | |
| 105 | ||
| 106 | /** | |
| 107 | * Returns the decimal precision configuration for this field. | |
| 108 | * | |
| 109 | * @return the {@link FixedFormatDecimalData}, or {@code null} if no decimal annotation is present | |
| 110 | */ | |
| 111 | public FixedFormatDecimalData getFixedFormatDecimalData() { | |
| 112 |
1
1. getFixedFormatDecimalData : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FormatInstructions::getFixedFormatDecimalData → KILLED |
return fixedFormatDecimalData; |
| 113 | } | |
| 114 | ||
| 115 | /** | |
| 116 | * Returns the number sign configuration for this field. | |
| 117 | * | |
| 118 | * @return the {@link FixedFormatNumberData}, or {@code null} if no number annotation is present | |
| 119 | */ | |
| 120 | public FixedFormatNumberData getFixedFormatNumberData() { | |
| 121 |
1
1. getFixedFormatNumberData : replaced return value with null for com/ancientprogramming/fixedformat4j/format/FormatInstructions::getFixedFormatNumberData → KILLED |
return fixedFormatNumberData; |
| 122 | } | |
| 123 | ||
| 124 | public String toString() { | |
| 125 |
1
1. toString : replaced return value with "" for com/ancientprogramming/fixedformat4j/format/FormatInstructions::toString → SURVIVED |
return String.format("FormatInstructions{length=%d, alignment=%s, paddingChar='%c', fixedFormatPatternData=%s, fixedFormatBooleanData=%s, fixedFormatNumberData=%s, fixedFormatDecimalData=%s}", |
| 126 | length, alignment, paddingChar, fixedFormatPatternData, fixedFormatBooleanData, fixedFormatNumberData, fixedFormatDecimalData); | |
| 127 | } | |
| 128 | } | |
Mutations | ||
| 67 |
1.1 |
|
| 76 |
1.1 |
|
| 85 |
1.1 |
|
| 94 |
1.1 |
|
| 103 |
1.1 |
|
| 112 |
1.1 |
|
| 121 |
1.1 |
|
| 125 |
1.1 |