53 | * The following schema fragment specifies the expected content contained within
54 | * this class.
55 | *
44 | * Tipo de formatadores suportados. Usados junto a defini��o de novos
45 | * formatadores.
46 | *
47 | *
48 | *
49 | *
50 | *
54 | * The following schema fragment specifies the expected content contained within
55 | * this class.
56 | *
53 | * The following schema fragment specifies the expected content contained within
54 | * this class.
55 | *
53 | * The following schema fragment specifies the expected content contained within
54 | * this class.
55 | *
44 | * Tipos usados para obten��o dos campos de texto para java. No caso representa
45 | * os tipos java poss�veis para um campo.
46 | *
47 | *
48 | *
49 | *
50 | *
54 | * The following schema fragment specifies the expected content contained within
55 | * this class.
56 | *
48 | * Field � a unidade b�sica de informa��o de um registro, um field est� para um
49 | * registro assim como uma coluna de banco de dados est� para uma tabela.
50 | *
51 | *
52 | *
53 | *
54 | *
55 | *
56 | */
57 | @XmlAccessorType(XmlAccessType.FIELD)
58 | @XmlType(name = "MetaField", propOrder = {
59 |
60 | })
61 | public class MetaField {
62 |
63 | @XmlElement(name = "Filler")
64 | protected MetaFiller filler;
65 | @XmlElement(name = "Formatter")
66 | protected MetaFormatter formatter;
67 | @XmlAttribute
68 | protected Boolean blankAccepted;
69 | @XmlAttribute
70 | protected Boolean truncate;
71 | @XmlAttribute
72 | protected EnumFormats format;
73 | @XmlAttribute(required = true)
74 | protected int length;
75 | @XmlAttribute(required = true)
76 | protected String name;
77 | @XmlAttribute
78 | protected EnumPaddings padding;
79 | @XmlAttribute
80 | protected EnumTypes type;
81 | @XmlAttribute
82 | protected String value;
83 |
84 | /**
85 | * Gets the value of the filler property.
86 | *
87 | * @return possible object is {@link MetaFiller }
88 | *
89 | */
90 | public MetaFiller getFiller() {
91 | return filler;
92 | }
93 |
94 | /**
95 | * Sets the value of the filler property.
96 | *
97 | * @param value
98 | * allowed object is {@link MetaFiller }
99 | *
100 | */
101 | public void setFiller(MetaFiller value) {
102 | this.filler = value;
103 | }
104 |
105 | /**
106 | * Gets the value of the formatter property.
107 | *
108 | * @return possible object is {@link MetaFormatter }
109 | *
110 | */
111 | public MetaFormatter getFormatter() {
112 | return formatter;
113 | }
114 |
115 | /**
116 | * Sets the value of the formatter property.
117 | *
118 | * @param value
119 | * allowed object is {@link MetaFormatter }
120 | *
121 | */
122 | public void setFormatter(MetaFormatter value) {
123 | this.formatter = value;
124 | }
125 |
126 | /**
127 | * Gets the value of the blankAccepted property.
128 | *
129 | * @return possible object is {@link Boolean }
130 | *
131 | */
132 | public boolean isBlankAccepted() {
133 | if (blankAccepted == null) {
134 | return false;
135 | } else {
136 | return blankAccepted;
137 | }
138 | }
139 |
140 | /**
141 | * Sets the value of the blankAccepted property.
142 | *
143 | * @param value
144 | * allowed object is {@link Boolean }
145 | *
146 | */
147 | public void setBlankAccepted(Boolean value) {
148 | this.blankAccepted = value;
149 | }
150 |
151 | /**
152 | * Gets the value of the truncate property.
153 | *
154 | * @return possible object is {@link Boolean }
155 | *
156 | */
157 | public boolean isTruncate() {
158 | if (truncate == null) {
159 | return false;
160 | } else {
161 | return truncate;
162 | }
163 | }
164 |
165 | /**
166 | * Sets the value of the blankAccepted property.
167 | *
168 | * @param value
169 | * allowed object is {@link Boolean }
170 | *
171 | */
172 | public void setTruncate(Boolean value) {
173 | this.truncate = value;
174 | }
175 |
176 | /**
177 | * Gets the value of the format property.
178 | *
179 | * @return possible object is {@link EnumFormats }
180 | *
181 | */
182 | public EnumFormats getFormat() {
183 | return format;
184 | }
185 |
186 | /**
187 | * Sets the value of the format property.
188 | *
189 | * @param value
190 | * allowed object is {@link EnumFormats }
191 | *
192 | */
193 | public void setFormat(EnumFormats value) {
194 | this.format = value;
195 | }
196 |
197 | /**
198 | * Gets the value of the length property.
199 | *
200 | */
201 | public int getLength() {
202 | return length;
203 | }
204 |
205 | /**
206 | * Sets the value of the length property.
207 | *
208 | */
209 | public void setLength(int value) {
210 | this.length = value;
211 | }
212 |
213 | /**
214 | * Gets the value of the name property.
215 | *
216 | * @return possible object is {@link String }
217 | *
218 | */
219 | public String getName() {
220 | return name;
221 | }
222 |
223 | /**
224 | * Sets the value of the name property.
225 | *
226 | * @param value
227 | * allowed object is {@link String }
228 | *
229 | */
230 | public void setName(String value) {
231 | this.name = value;
232 | }
233 |
234 | /**
235 | * Gets the value of the padding property.
236 | *
237 | * @return possible object is {@link EnumPaddings }
238 | *
239 | */
240 | public EnumPaddings getPadding() {
241 | if (padding == null) {
242 | return EnumPaddings.WHITE_SPACE_RIGHT;
243 | } else {
244 | return padding;
245 | }
246 | }
247 |
248 | /**
249 | * Sets the value of the padding property.
250 | *
251 | * @param value
252 | * allowed object is {@link EnumPaddings }
253 | *
254 | */
255 | public void setPadding(EnumPaddings value) {
256 | this.padding = value;
257 | }
258 |
259 | /**
260 | * Gets the value of the type property.
261 | *
262 | * @return possible object is {@link EnumTypes }
263 | *
264 | */
265 | public EnumTypes getType() {
266 | if (type == null) {
267 | return EnumTypes.STRING;
268 | } else {
269 | return type;
270 | }
271 | }
272 |
273 | /**
274 | * Sets the value of the type property.
275 | *
276 | * @param value
277 | * allowed object is {@link EnumTypes }
278 | *
279 | */
280 | public void setType(EnumTypes value) {
281 | this.type = value;
282 | }
283 |
284 | /**
285 | * Gets the value of the value property.
286 | *
287 | * @return possible object is {@link String }
288 | *
289 | */
290 | public String getValue() {
291 | if (value == null) {
292 | return " ";
293 | } else {
294 | return value;
295 | }
296 | }
297 |
298 | /**
299 | * Sets the value of the value property.
300 | *
301 | * @param value
302 | * allowed object is {@link String }
303 | *
304 | */
305 | public void setValue(String value) {
306 | this.value = value;
307 | }
308 |
309 | }
310 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaFiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
31 | // See
49 | * Instrumento utilizado para preencher um field com um formato e caracteres pr�
50 | * definidos.
51 | *
52 | *
53 | *
54 | *
55 | *
56 | *
57 | */
58 | @XmlAccessorType(XmlAccessType.FIELD)
59 | @XmlType(name = "MetaFiller")
60 | public class MetaFiller {
61 |
62 | @XmlAttribute(required = true)
63 | protected String padding;
64 | @XmlAttribute
65 | protected EnumSide sideToFill;
66 |
67 | /**
68 | * Gets the value of the padding property.
69 | *
70 | * @return possible object is {@link String }
71 | *
72 | */
73 | public String getPadding() {
74 | return padding;
75 | }
76 |
77 | /**
78 | * Sets the value of the padding property.
79 | *
80 | * @param value
81 | * allowed object is {@link String }
82 | *
83 | */
84 | public void setPadding(String value) {
85 | this.padding = value;
86 | }
87 |
88 | /**
89 | * Gets the value of the sideToFill property.
90 | *
91 | * @return possible object is {@link Side }
92 | *
93 | */
94 | public EnumSide getSideToFill() {
95 | if (sideToFill == null) {
96 | return EnumSide.LEFT;
97 | } else {
98 | return sideToFill;
99 | }
100 | }
101 |
102 | /**
103 | * Sets the value of the sideToFill property.
104 | *
105 | * @param value
106 | * allowed object is {@link Side }
107 | *
108 | */
109 | public void setSideToFill(EnumSide value) {
110 | this.sideToFill = value;
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaFlatFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
31 | // See
47 | * Flat File � um tipo de arquivo texto com informa��es estruturadas com base em
48 | * formata��es e estruturas pr� definidas. veja mais em (link).
49 | *
50 | *
51 | *
52 | *
53 | *
54 | *
55 | */
56 | @XmlAccessorType(XmlAccessType.FIELD)
57 | @XmlType(name = "MetaFlatFile", propOrder = { "layout", "groupOfRecords" })
58 | public class MetaFlatFile {
59 |
60 | protected MetaLayout layout;
61 | @XmlElement(name = "GroupOfRecords", required = true)
62 | protected MetaGroupRecords groupOfRecords;
63 |
64 | /**
65 | * Gets the value of the layout property.
66 | *
67 | * @return possible object is {@link MetaLayout }
68 | *
69 | */
70 | public MetaLayout getLayout() {
71 | return layout;
72 | }
73 |
74 | /**
75 | * Sets the value of the layout property.
76 | *
77 | * @param value
78 | * allowed object is {@link MetaLayout }
79 | *
80 | */
81 | public void setLayout(MetaLayout value) {
82 | this.layout = value;
83 | }
84 |
85 | /**
86 | * Gets the value of the groupOfRecords property.
87 | *
88 | * @return possible object is {@link MetaGroupRecords }
89 | *
90 | */
91 | public MetaGroupRecords getGroupOfRecords() {
92 | return groupOfRecords;
93 | }
94 |
95 | /**
96 | * Sets the value of the groupOfRecords property.
97 | *
98 | * @param value
99 | * allowed object is {@link MetaGroupRecords }
100 | *
101 | */
102 | public void setGroupOfRecords(MetaGroupRecords value) {
103 | this.groupOfRecords = value;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaFormatter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
31 | // See fields;
65 | @XmlElement(name = "SequencialNumber")
66 | protected MetaOrderedField sequencialNumber;
67 |
68 | /**
69 | * Gets the value of the idType property.
70 | *
71 | * @return possible object is {@link MetaOrderedField }
72 | *
73 | */
74 | public MetaOrderedField getIdType() {
75 | return idType;
76 | }
77 |
78 | /**
79 | * Sets the value of the idType property.
80 | *
81 | * @param value
82 | * allowed object is {@link MetaOrderedField }
83 | *
84 | */
85 | public void setIdType(MetaOrderedField value) {
86 | this.idType = value;
87 | }
88 |
89 | /**
90 | * Gets the value of the fields property.
91 | *
92 | *
93 | * This accessor method returns a reference to the live list, not a
94 | * snapshot. Therefore any modification you make to the returned list will
95 | * be present inside the JAXB object. This is why there is not a
96 | * set
method for the fields property.
97 | *
98 | *
99 | * For example, to add a new item, do as follows:
100 | *
101 | *
102 | * getFields().add(newItem);
103 | *
104 | *
105 | *
106 | *
107 | * Objects of the following type(s) are allowed in the list
108 | * {@link MetaField }
109 | *
110 | *
111 | */
112 | public List getFields() {
113 | if (fields == null) {
114 | fields = new ArrayList();
115 | }
116 | return this.fields;
117 | }
118 |
119 | /**
120 | * Gets the value of the sequencialNumber property.
121 | *
122 | * @return possible object is {@link MetaOrderedField }
123 | *
124 | */
125 | public MetaOrderedField getSequencialNumber() {
126 | return sequencialNumber;
127 | }
128 |
129 | /**
130 | * Sets the value of the sequencialNumber property.
131 | *
132 | * @param value
133 | * allowed object is {@link MetaOrderedField }
134 | *
135 | */
136 | public void setSequencialNumber(MetaOrderedField value) {
137 | this.sequencialNumber = value;
138 | }
139 |
140 | public static class IdType extends JAXBElement {
141 |
142 | /**
143 | * {@code serialVersionUID = -8934480908648452108L}
144 | */
145 | private static final long serialVersionUID = -8934480908648452108L;
146 |
147 | protected final static QName NAME = new QName("", "IdType");
148 |
149 | public IdType(MetaOrderedField value) {
150 | super(NAME, ((Class) MetaOrderedField.class),
151 | MetaGroupFields.class, value);
152 | }
153 |
154 | }
155 |
156 | public static class SequencialNumber extends JAXBElement {
157 |
158 | /**
159 | * {@code serialVersionUID = 3923837730914132777L}
160 | */
161 | private static final long serialVersionUID = 3923837730914132777L;
162 |
163 | protected final static QName NAME = new QName("", "SequencialNumber");
164 |
165 | public SequencialNumber(MetaOrderedField value) {
166 | super(NAME, ((Class) MetaOrderedField.class),
167 | MetaGroupFields.class, value);
168 | }
169 |
170 | }
171 |
172 | }
173 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaGroupRecords.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
31 | // See http://java.sun.com/xml/jaxb
32 | // Any modifications to this file will be lost upon recompilation of the source schema.
33 | // Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
34 | //
35 |
36 | package org.jrimum.texgit.language;
37 |
38 | import java.util.ArrayList;
39 | import java.util.List;
40 |
41 | import javax.xml.bind.annotation.XmlAccessType;
42 | import javax.xml.bind.annotation.XmlAccessorType;
43 | import javax.xml.bind.annotation.XmlElement;
44 | import javax.xml.bind.annotation.XmlType;
45 |
46 | /**
47 | *
48 | *
49 | *
50 | * Conjunto de records de um flatfile ou relacionados a um outro record.
51 | *
52 | *
53 | *
54 | *
55 | *
56 | *
57 | */
58 | @XmlAccessorType(XmlAccessType.FIELD)
59 | @XmlType(name = "MetaGroupRecords", propOrder = { "records" })
60 | public class MetaGroupRecords {
61 |
62 | @XmlElement(name = "Record", required = true)
63 | protected List records;
64 |
65 | /**
66 | * Gets the value of the records property.
67 | *
68 | *
69 | * This accessor method returns a reference to the live list, not a
70 | * snapshot. Therefore any modification you make to the returned list will
71 | * be present inside the JAXB object. This is why there is not a
72 | * set
method for the records property.
73 | *
74 | *
75 | * For example, to add a new item, do as follows:
76 | *
77 | *
78 | * getRecords().add(newItem);
79 | *
80 | *
81 | *
82 | *
83 | * Objects of the following type(s) are allowed in the list
84 | * {@link MetaRecord }
85 | *
86 | *
87 | */
88 | public List getRecords() {
89 | if (records == null) {
90 | records = new ArrayList();
91 | }
92 | return this.records;
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaLayout.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
31 | // See http://java.sun.com/xml/jaxb
32 | // Any modifications to this file will be lost upon recompilation of the source schema.
33 | // Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
34 | //
35 |
36 | package org.jrimum.texgit.language;
37 |
38 | import javax.xml.bind.annotation.XmlAccessType;
39 | import javax.xml.bind.annotation.XmlAccessorType;
40 | import javax.xml.bind.annotation.XmlType;
41 |
42 | /**
43 | *
44 | *
45 | *
46 | * Tags para informar o layout do flafile definido.
47 | *
48 | *
49 | *
50 | *
51 | *
52 | *
53 | */
54 | @XmlAccessorType(XmlAccessType.FIELD)
55 | @XmlType(name = "MetaLayout", propOrder = {
56 |
57 | })
58 | public class MetaLayout {
59 |
60 | protected String name;
61 | protected String version;
62 | protected String description;
63 |
64 | /**
65 | * Gets the value of the name property.
66 | *
67 | * @return possible object is {@link String }
68 | *
69 | */
70 | public String getName() {
71 | return name;
72 | }
73 |
74 | /**
75 | * Sets the value of the name property.
76 | *
77 | * @param value
78 | * allowed object is {@link String }
79 | *
80 | */
81 | public void setName(String value) {
82 | this.name = value;
83 | }
84 |
85 | /**
86 | * Gets the value of the version property.
87 | *
88 | * @return possible object is {@link String }
89 | *
90 | */
91 | public String getVersion() {
92 | return version;
93 | }
94 |
95 | /**
96 | * Sets the value of the version property.
97 | *
98 | * @param value
99 | * allowed object is {@link String }
100 | *
101 | */
102 | public void setVersion(String value) {
103 | this.version = value;
104 | }
105 |
106 | /**
107 | * Gets the value of the description property.
108 | *
109 | * @return possible object is {@link String }
110 | *
111 | */
112 | public String getDescription() {
113 | return description;
114 | }
115 |
116 | /**
117 | * Sets the value of the description property.
118 | *
119 | * @param value
120 | * allowed object is {@link String }
121 | *
122 | */
123 | public void setDescription(String value) {
124 | this.description = value;
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaOrderedField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
31 | // See http://java.sun.com/xml/jaxb
32 | // Any modifications to this file will be lost upon recompilation of the source schema.
33 | // Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
34 | //
35 |
36 | package org.jrimum.texgit.language;
37 |
38 | import javax.xml.bind.annotation.XmlAccessType;
39 | import javax.xml.bind.annotation.XmlAccessorType;
40 | import javax.xml.bind.annotation.XmlAttribute;
41 | import javax.xml.bind.annotation.XmlType;
42 |
43 | /**
44 | *
45 | *
46 | *
47 | * Para defini��o da posi��o.
48 | *
49 | *
50 | *
51 | *
52 | *
53 | *
54 | */
55 | @XmlAccessorType(XmlAccessType.FIELD)
56 | @XmlType(name = "MetaOrderedField")
57 | public class MetaOrderedField extends MetaField {
58 |
59 | @XmlAttribute(required = true)
60 | protected int position;
61 |
62 | /**
63 | * Gets the value of the position property.
64 | *
65 | */
66 | public int getPosition() {
67 | return position;
68 | }
69 |
70 | /**
71 | * Sets the value of the position property.
72 | *
73 | */
74 | public void setPosition(int value) {
75 | this.position = value;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 |
30 | //
31 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
32 | // See http://java.sun.com/xml/jaxb
33 | // Any modifications to this file will be lost upon recompilation of the source schema.
34 | // Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
35 | //
36 |
37 | package org.jrimum.texgit.language;
38 |
39 | import javax.xml.bind.annotation.XmlAccessType;
40 | import javax.xml.bind.annotation.XmlAccessorType;
41 | import javax.xml.bind.annotation.XmlAttribute;
42 | import javax.xml.bind.annotation.XmlElement;
43 | import javax.xml.bind.annotation.XmlType;
44 |
45 | /**
46 | *
47 | *
48 | *
49 | * Uma esp�cie de container de fields numa forma mais simples, usualmente �
50 | * conhecido como Registro ou Bloco.
51 | *
52 | *
53 | *
54 | *
55 | *
56 | *
57 | */
58 | @XmlAccessorType(XmlAccessType.FIELD)
59 | @XmlType(name = "MetaRecord", propOrder = { "groupOfFields",
60 | "groupOfInnerRecords" })
61 | public class MetaRecord {
62 |
63 | @XmlElement(name = "GroupOfFields", required = true)
64 | protected MetaGroupFields groupOfFields;
65 | @XmlElement(name = "GroupOfInnerRecords")
66 | protected MetaGroupRecords groupOfInnerRecords;
67 | @XmlAttribute
68 | protected String description;
69 | @XmlAttribute
70 | protected String name;
71 | @XmlAttribute
72 | protected Boolean repeatable;
73 |
74 | /**
75 | * Gets the value of the groupOfFields property.
76 | *
77 | * @return possible object is {@link MetaGroupFields }
78 | *
79 | */
80 | public MetaGroupFields getGroupOfFields() {
81 | return groupOfFields;
82 | }
83 |
84 | /**
85 | * Sets the value of the groupOfFields property.
86 | *
87 | * @param value
88 | * allowed object is {@link MetaGroupFields }
89 | *
90 | */
91 | public void setGroupOfFields(MetaGroupFields value) {
92 | this.groupOfFields = value;
93 | }
94 |
95 | /**
96 | * Gets the value of the groupOfInnerRecords property.
97 | *
98 | * @return possible object is {@link MetaGroupRecords }
99 | *
100 | */
101 | public MetaGroupRecords getGroupOfInnerRecords() {
102 | return groupOfInnerRecords;
103 | }
104 |
105 | /**
106 | * Sets the value of the groupOfInnerRecords property.
107 | *
108 | * @param value
109 | * allowed object is {@link MetaGroupRecords }
110 | *
111 | */
112 | public void setGroupOfInnerRecords(MetaGroupRecords value) {
113 | this.groupOfInnerRecords = value;
114 | }
115 |
116 | /**
117 | * Gets the value of the description property.
118 | *
119 | * @return possible object is {@link String }
120 | *
121 | */
122 | public String getDescription() {
123 | return description;
124 | }
125 |
126 | /**
127 | * Sets the value of the description property.
128 | *
129 | * @param value
130 | * allowed object is {@link String }
131 | *
132 | */
133 | public void setDescription(String value) {
134 | this.description = value;
135 | }
136 |
137 | /**
138 | * Gets the value of the name property.
139 | *
140 | * @return possible object is {@link String }
141 | *
142 | */
143 | public String getName() {
144 | return name;
145 | }
146 |
147 | /**
148 | * Sets the value of the name property.
149 | *
150 | * @param value
151 | * allowed object is {@link String }
152 | *
153 | */
154 | public void setName(String value) {
155 | this.name = value;
156 | }
157 |
158 | /**
159 | * Gets the value of the repeatable property.
160 | *
161 | * @return possible object is {@link Boolean }
162 | *
163 | */
164 | public boolean isRepeatable() {
165 | if (repeatable == null) {
166 | return false;
167 | } else {
168 | return repeatable;
169 | }
170 | }
171 |
172 | /**
173 | * Sets the value of the repeatable property.
174 | *
175 | * @param value
176 | * allowed object is {@link Boolean }
177 | *
178 | */
179 | public void setRepeatable(Boolean value) {
180 | this.repeatable = value;
181 | }
182 |
183 | }
184 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/MetaTexgit.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 |
30 | //
31 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
32 | // See http://java.sun.com/xml/jaxb
33 | // Any modifications to this file will be lost upon recompilation of the source schema.
34 | // Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
35 | //
36 |
37 | package org.jrimum.texgit.language;
38 |
39 | import javax.xml.bind.annotation.XmlAccessType;
40 | import javax.xml.bind.annotation.XmlAccessorType;
41 | import javax.xml.bind.annotation.XmlAttribute;
42 | import javax.xml.bind.annotation.XmlElement;
43 | import javax.xml.bind.annotation.XmlRootElement;
44 | import javax.xml.bind.annotation.XmlType;
45 |
46 | /**
47 | *
48 | *
49 | *
50 | * Elemento root.
51 | *
52 | *
53 | *
54 | *
55 | *
56 | *
57 | */
58 | @XmlRootElement(name = "Texgit")
59 | @XmlAccessorType(XmlAccessType.FIELD)
60 | @XmlType(name = "MetaTexgit", propOrder = {
61 |
62 | })
63 | public class MetaTexgit {
64 |
65 | @XmlElement(name = "FlatFile", required = true)
66 | protected MetaFlatFile flatFile;
67 | @XmlAttribute
68 | protected String version;
69 |
70 | /**
71 | * Gets the value of the flatFile property.
72 | *
73 | * @return possible object is {@link MetaFlatFile }
74 | *
75 | */
76 | public MetaFlatFile getFlatFile() {
77 | return flatFile;
78 | }
79 |
80 | /**
81 | * Sets the value of the flatFile property.
82 | *
83 | * @param value
84 | * allowed object is {@link MetaFlatFile }
85 | *
86 | */
87 | public void setFlatFile(MetaFlatFile value) {
88 | this.flatFile = value;
89 | }
90 |
91 | /**
92 | * Gets the value of the version property.
93 | *
94 | * @return possible object is {@link String }
95 | *
96 | */
97 | public String getVersion() {
98 | if (version == null) {
99 | return "1.0-academic";
100 | } else {
101 | return version;
102 | }
103 | }
104 |
105 | /**
106 | * Sets the value of the version property.
107 | *
108 | * @param value
109 | * allowed object is {@link String }
110 | *
111 | */
112 | public void setVersion(String value) {
113 | this.version = value;
114 | }
115 |
116 | }
117 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/ObjectFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
31 | // See http://java.sun.com/xml/jaxb
32 | // Any modifications to this file will be lost upon recompilation of the source schema.
33 | // Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
34 | //
35 |
36 | package org.jrimum.texgit.language;
37 |
38 | import javax.xml.bind.JAXBElement;
39 | import javax.xml.bind.annotation.XmlElementDecl;
40 | import javax.xml.bind.annotation.XmlRegistry;
41 | import javax.xml.namespace.QName;
42 |
43 | /**
44 | * This object contains factory methods for each Java content interface and Java
45 | * element interface generated in the texgit.language package.
46 | *
47 | * An ObjectFactory allows you to programatically construct new instances of the
48 | * Java representation for XML content. The Java representation of XML content
49 | * can consist of schema derived interfaces and classes representing the binding
50 | * of schema type definitions, element declarations and model groups. Factory
51 | * methods for each of these are provided in this class.
52 | *
53 | */
54 | @XmlRegistry
55 | public class ObjectFactory {
56 |
57 | private final static QName TEXGIT_QNAME = new QName(
58 | "http://jrimum.org/texgit", "Texgit");
59 |
60 | /**
61 | * Create a new ObjectFactory that can be used to create new instances of
62 | * schema derived classes for package: texgit.language
63 | *
64 | */
65 | public ObjectFactory() {
66 | }
67 |
68 | /**
69 | * Create an instance of {@link MetaField }
70 | *
71 | */
72 | public MetaField createMetaField() {
73 | return new MetaField();
74 | }
75 |
76 | /**
77 | * Create an instance of {@link MetaFlatFile }
78 | *
79 | */
80 | public MetaFlatFile createMetaFlatFile() {
81 | return new MetaFlatFile();
82 | }
83 |
84 | /**
85 | * Create an instance of {@link MetaOrderedField }
86 | *
87 | */
88 | public MetaOrderedField createMetaOrderedField() {
89 | return new MetaOrderedField();
90 | }
91 |
92 | /**
93 | * Create an instance of {@link MetaRecord }
94 | *
95 | */
96 | public MetaRecord createMetaRecord() {
97 | return new MetaRecord();
98 | }
99 |
100 | /**
101 | * Create an instance of {@link MetaLayout }
102 | *
103 | */
104 | public MetaLayout createMetaLayout() {
105 | return new MetaLayout();
106 | }
107 |
108 | /**
109 | * Create an instance of {@link MetaTexgit }
110 | *
111 | */
112 | public MetaTexgit createMetaTexgit() {
113 | return new MetaTexgit();
114 | }
115 |
116 | /**
117 | * Create an instance of {@link MetaFormatter }
118 | *
119 | */
120 | public MetaFormatter createMetaFormatter() {
121 | return new MetaFormatter();
122 | }
123 |
124 | /**
125 | * Create an instance of {@link MetaGroupFields }
126 | *
127 | */
128 | public MetaGroupFields createMetaGroupFields() {
129 | return new MetaGroupFields();
130 | }
131 |
132 | /**
133 | * Create an instance of {@link MetaGroupRecords }
134 | *
135 | */
136 | public MetaGroupRecords createMetaGroupRecords() {
137 | return new MetaGroupRecords();
138 | }
139 |
140 | /**
141 | * Create an instance of {@link MetaFiller }
142 | *
143 | */
144 | public MetaFiller createMetaFiller() {
145 | return new MetaFiller();
146 | }
147 |
148 | /**
149 | * Create an instance of {@link JAXBElement }{@code <}{@link MetaTexgit }{@code >}}
150 | *
151 | */
152 | @XmlElementDecl(namespace = "http://jrimum.org/texgit", name = "Texgit")
153 | public JAXBElement createTexgit(MetaTexgit value) {
154 | return new JAXBElement(TEXGIT_QNAME, MetaTexgit.class,
155 | null, value);
156 | }
157 |
158 | /**
159 | * Create an instance of {@link MetaGroupFields.SequencialNumber }}
160 | *
161 | */
162 | @XmlElementDecl(namespace = "", name = "SequencialNumber", scope = MetaGroupFields.class)
163 | public MetaGroupFields.SequencialNumber createMetaGroupFieldsSequencialNumber(
164 | MetaOrderedField value) {
165 | return new MetaGroupFields.SequencialNumber(value);
166 | }
167 |
168 | /**
169 | * Create an instance of {@link MetaGroupFields.IdType }}
170 | *
171 | */
172 | @XmlElementDecl(namespace = "", name = "IdType", scope = MetaGroupFields.class)
173 | public MetaGroupFields.IdType createMetaGroupFieldsIdType(
174 | MetaOrderedField value) {
175 | return new MetaGroupFields.IdType(value);
176 | }
177 |
178 | }
179 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/language/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 03/08/2008 - 12:27:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 03/08/2008 - 12:27:56
27 | *
28 | */
29 | //
30 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB)
31 | // Reference Implementation, vJAXB 2.0 in JDK 1.6
32 | // See http://java.sun.com/xml/jaxb
33 | // Any modifications to this file will be lost upon recompilation of the source
34 | // schema.
35 | // Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
36 | //
37 |
38 | @javax.xml.bind.annotation.XmlSchema(namespace = "http://jrimum.org/texgit")
39 | package org.jrimum.texgit.language;
40 |
41 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/AbstractStringOfFields.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type;
30 |
31 | import static java.lang.String.format;
32 |
33 | import java.util.ArrayList;
34 | import java.util.Collection;
35 | import java.util.Iterator;
36 | import java.util.List;
37 | import java.util.ListIterator;
38 |
39 | import org.apache.commons.lang.StringUtils;
40 | import org.jrimum.texgit.TextStream;
41 | import org.jrimum.utilix.Collections;
42 | import org.jrimum.utilix.Objects;
43 |
44 | /**
45 | * @author Gilmar P.S.L.
46 | *
47 | * @param
48 | */
49 | @SuppressWarnings("serial")
50 | public abstract class AbstractStringOfFields> implements TextStream, List, Cloneable{
51 |
52 | /**
53 | *
54 | */
55 | private ArrayList fields;
56 |
57 | /**
58 | *
59 | */
60 | public AbstractStringOfFields() {
61 |
62 | fields = new ArrayList();
63 | }
64 |
65 | /**
66 | *
67 | */
68 | public AbstractStringOfFields(Integer size) {
69 |
70 | Objects.checkNotNull(size, "size");
71 |
72 | if (size > 0) {
73 | fields = new ArrayList(size);
74 | for (int i = 1; i <= size; i++){
75 | fields.add(null);
76 | }
77 | } else {
78 | throw new IllegalArgumentException(format("A quantidade de campos [%s] deve ser um número natural > 0!", size));
79 | }
80 | }
81 |
82 | @SuppressWarnings("unchecked")
83 | @Override
84 | protected AbstractStringOfFields clone() throws CloneNotSupportedException {
85 |
86 | //Clona apenas com uma referência a fields.
87 | AbstractStringOfFields sof = (AbstractStringOfFields) super.clone();
88 |
89 | //Clonagem real
90 | sof.fields = new ArrayList();
91 |
92 | for(G gf : fields)
93 | sof.fields.add((G) gf.clone());
94 |
95 | return sof;
96 | }
97 |
98 | /**
99 | *
100 | * A leitrua de uma string, ou melhor, a divisão de uma string em fields,
101 | * não ocorre sem uma lógica. Assim este método deve ser implementado por
102 | * cada subclasse.
103 | *
104 | *
105 | * @see org.jrimum.texgit.ReadWriteStream#read(Object)
106 | */
107 | public abstract void read(String lineOfField);
108 |
109 | /**
110 | *
111 | * Escreve os campos na ordem em que estão dispostos na lista em uma única linha (string).
112 | *
113 | *
114 | * @see org.jrimum.texgit.ReadWriteStream#write()
115 | */
116 | public String write() {
117 |
118 | StringBuilder lineOfFields = new StringBuilder(StringUtils.EMPTY);
119 |
120 | Objects.checkNotNull(fields, "Fields == null");
121 | Collections.checkNotEmpty(fields, "Coleção de fields vazia!");
122 |
123 | for (G field : fields) {
124 |
125 | try {
126 |
127 | lineOfFields.append(field.write());
128 |
129 | } catch (Exception e) {
130 |
131 | throw new IllegalStateException(
132 | format(
133 | "Erro ao tentar escrever o campo \"%s\" com valor [%s] na posição [%s] no layout do registro.",
134 | field.getName(), field.getValue(), fields
135 | .indexOf(field)+1),e);
136 | }
137 | }
138 |
139 | return lineOfFields.toString();
140 | }
141 |
142 | /**
143 | * @return the fields
144 | */
145 | public List getFields() {
146 | return fields;
147 | }
148 |
149 | /**
150 | * @see java.util.List#add(java.lang.Object)
151 | */
152 | public boolean add(G e) {
153 |
154 | return fields.add(e);
155 | }
156 |
157 | /**
158 | * @see java.util.List#add(int, java.lang.Object)
159 | */
160 | public void add(int index, G element) {
161 |
162 | fields.add(index, element);
163 | }
164 |
165 | /**
166 | * @see java.util.List#addAll(java.util.Collection)
167 | */
168 | public boolean addAll(Collection extends G> c) {
169 |
170 | return fields.addAll(c);
171 | }
172 |
173 | /**
174 | * @see java.util.List#addAll(int, java.util.Collection)
175 | */
176 | public boolean addAll(int index, Collection extends G> c) {
177 |
178 | return fields.addAll(index, c);
179 | }
180 |
181 | /**
182 | * @see java.util.List#clear()
183 | */
184 | public void clear() {
185 |
186 | fields.clear();
187 | }
188 |
189 | /**
190 | * @see java.util.List#contains(java.lang.Object)
191 | */
192 | public boolean contains(Object o) {
193 |
194 | return fields.contains(o);
195 | }
196 |
197 | /**
198 | * @see java.util.List#containsAll(java.util.Collection)
199 | */
200 | public boolean containsAll(Collection> c) {
201 |
202 | return fields.containsAll(c);
203 | }
204 |
205 | /**
206 | * @see java.util.List#get(int)
207 | */
208 | public G get(int index) {
209 |
210 | return fields.get(index);
211 | }
212 |
213 | /**
214 | * @see java.util.List#indexOf(java.lang.Object)
215 | */
216 | public int indexOf(Object o) {
217 |
218 | return fields.indexOf(o);
219 | }
220 |
221 | /**
222 | * @see java.util.List#isEmpty()
223 | */
224 | public boolean isEmpty() {
225 |
226 | return fields.isEmpty();
227 | }
228 |
229 | /**
230 | * @see java.util.List#iterator()
231 | */
232 | public Iterator iterator() {
233 |
234 | return fields.iterator();
235 | }
236 |
237 | /**
238 | * @see java.util.List#lastIndexOf(java.lang.Object)
239 | */
240 | public int lastIndexOf(Object o) {
241 |
242 | return fields.indexOf(o);
243 | }
244 |
245 | /**
246 | * @see java.util.List#listIterator()
247 | */
248 | public ListIterator listIterator() {
249 |
250 | return fields.listIterator();
251 | }
252 |
253 | /**
254 | * @see java.util.List#listIterator(int)
255 | */
256 | public ListIterator listIterator(int index) {
257 |
258 | return fields.listIterator(index);
259 | }
260 |
261 | /**
262 | * @see java.util.List#remove(int)
263 | */
264 | public G remove(int index) {
265 |
266 | return fields.remove(index);
267 | }
268 |
269 | /**
270 | * @see java.util.List#remove(java.lang.Object)
271 | */
272 | public boolean remove(Object o) {
273 |
274 | return fields.remove(o);
275 | }
276 |
277 | /**
278 | * @see java.util.List#removeAll(java.util.Collection)
279 | */
280 | public boolean removeAll(Collection> c) {
281 |
282 | return fields.removeAll(c);
283 | }
284 |
285 | /**
286 | * @see java.util.List#retainAll(java.util.Collection)
287 | */
288 | public boolean retainAll(Collection> c) {
289 |
290 | return fields.retainAll(c);
291 | }
292 |
293 | /**
294 | * @see java.util.List#set(int, java.lang.Object)
295 | */
296 | public G set(int index, G element) {
297 |
298 | return fields.set(index, element);
299 | }
300 |
301 | /**
302 | * @see java.util.List#size()
303 | */
304 | public int size() {
305 |
306 | return fields.size();
307 | }
308 |
309 | /**
310 | * @see java.util.List#subList(int, int)
311 | */
312 | public List subList(int fromIndex, int toIndex) {
313 |
314 | return fields.subList(fromIndex, toIndex);
315 | }
316 |
317 | /**
318 | * @see java.util.List#toArray()
319 | */
320 | public Object[] toArray() {
321 |
322 | return fields.toArray();
323 | }
324 |
325 | /**
326 | * @see java.util.List#toArray(Object[])
327 | */
328 | public T[] toArray(T[] a) {
329 |
330 | return fields.toArray(a);
331 | }
332 | }
333 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/Field.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type;
30 |
31 | import java.text.Format;
32 |
33 | import org.jrimum.texgit.TextStream;
34 |
35 | /**
36 | * @author Gilmar P.S.L.
37 | *
38 | * @param
39 | */
40 | public interface Field extends TextStream, Cloneable{
41 |
42 | public abstract String getName();
43 |
44 | public abstract void setName(String name);
45 |
46 | public abstract G getValue();
47 |
48 | public abstract void setValue(G value);
49 |
50 | public abstract Format getFormatter();
51 |
52 | public abstract void setFormatter(Format formatter);
53 |
54 | public abstract boolean isBlankAccepted();
55 |
56 | public abstract void setBlankAccepted(boolean blankAccepted);
57 |
58 | public abstract Field clone() throws CloneNotSupportedException;
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/Filler.java:
--------------------------------------------------------------------------------
1 | package org.jrimum.texgit.type;
2 |
3 | import java.io.Serializable;
4 |
5 | import org.jrimum.texgit.TextStream;
6 |
7 | public interface Filler extends Serializable{
8 |
9 | /**
10 | * Preenche o campo com o caracter especificado e no lado especificado.
11 | *
12 | *
13 | * Exemplo:
14 | *
15 | * Se sideToFill == SideToFill.LEFT
, o caracter especificado será adicionado à String
16 | * no lado esquerdo até que o campo fique com o tamanho que foi definido.
17 | *
18 | *
19 | * @param toFill
20 | * @param length
21 | * @return String preenchida
22 | *
23 | * @since 0.2
24 | */
25 | String fill(String toFill, int length);
26 |
27 | /**
28 | * Executa o método fill(String, int)
passando o parâmetro
29 | * toFill
como String.valueOf(toFill)
.
30 | *
31 | * @param tofill
32 | * @param length
33 | * @return String preenchida
34 | *
35 | * @see Filler#fill(String, int)
36 | *
37 | * @since 0.2
38 | */
39 | String fill(long tofill, int length);
40 |
41 | /**
42 | * Executa o método fill(String, int)
passando o parâmetro
43 | * toFill
como String.valueOf(toFill)
.
44 | *
45 | * @param tofill
46 | * @param length
47 | * @return String preenchida
48 | *
49 | * @see Filler#fill(String, int)
50 | *
51 | * @since 0.2
52 | */
53 | String fill(int tofill, int length);
54 |
55 | /**
56 | * Executa o método fill(String, int)
passando o parâmetro
57 | * toFill
como String.valueOf(toFill)
.
58 | *
59 | * @param tofill
60 | * @param length
61 | * @return String preenchida
62 | *
63 | * @see Filler#fill(String, int)
64 | *
65 | * @since 0.2
66 | */
67 | String fill(short tofill, int length);
68 |
69 | /**
70 | * Executa o método fill(String, int)
passando o parâmetro
71 | * toFill
como String.valueOf(toFill)
.
72 | *
73 | * @param tofill
74 | * @param length
75 | * @return String preenchida
76 | *
77 | * @see Filler#fill(String, int)
78 | *
79 | * @since 0.2
80 | */
81 | String fill(byte tofill, int length);
82 |
83 | /**
84 | * Executa o método fill(String, int)
passando o parâmetro
85 | * toFill
como String.valueOf(toFill)
.
86 | *
87 | * @param tofill
88 | * @param length
89 | * @return String preenchida
90 | *
91 | * @see Filler#fill(String, int)
92 | *
93 | * @since 0.2
94 | */
95 | String fill(char tofill, int length);
96 |
97 | /**
98 | * Executa o método fill(String, int)
passando o parâmetro
99 | * toFill
como String.valueOf(toFill)
.
100 | *
101 | * @param tofill
102 | * @param length
103 | * @return String preenchida
104 | *
105 | * @see Filler#fill(String, int)
106 | *
107 | * @since 0.2
108 | */
109 | String fill(double tofill, int length);
110 |
111 | /**
112 | * Executa o método fill(String, int)
passando o parâmetro
113 | * toFill
como String.valueOf(toFill)
.
114 | *
115 | * @param tofill
116 | * @param length
117 | * @return String preenchida
118 | *
119 | * @see Filler#fill(String, int)
120 | *
121 | * @since
122 | */
123 | String fill(float tofill, int length);
124 |
125 | /**
126 | * Executa o método fill(String, int)
passando o parâmetro
127 | * toFill
como toFill.toString()
.
128 | *
129 | *
130 | * Caso toFill
seja null
, o método
131 | * fill(String, int)
receberá uma String nula como parâmetro.
132 | *
133 | *
134 | * @param tofill
135 | * @param length
136 | * @return String preenchida
137 | *
138 | * @see Filler#fill(String, int)
139 | *
140 | * @since 0.2
141 | */
142 | String fill(Object tofill, int length);
143 |
144 | /**
145 | * Executa o método fill(String, int)
passando o parâmetro
146 | * toFill
como toFill.write()
.
147 | *
148 | *
149 | * Caso toFill
seja null
, o método
150 | * fill(String, int)
receberá uma String nula como parâmetro.
151 | *
152 | *
153 | * @param tofill
154 | * @param length
155 | * @return String preenchida
156 | *
157 | * @see Filler#fill(String, int)
158 | *
159 | * @since 0.2
160 | */
161 | String fill(TextStream tofill, int length);
162 | }
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/Fixed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type;
30 |
31 | /**
32 | * @author Gilmar P.S.L.
33 | *
34 | */
35 | public interface Fixed {
36 |
37 | /**
38 | * Informa a validade para a fixação de uma ou mais medidas. Exemplo:
39 | *
40 | *
41 | * {
42 | * isLenghtAsDefine();
43 | * isSizeAsDefine();
44 | * }
45 | *
46 | *
47 | * @return Indicativo se está de acordo com o definido
48 | *
49 | * @throws IllegalStateException
50 | */
51 | public abstract boolean isFixedAsDefined() throws IllegalStateException;
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/FixedField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type;
30 |
31 |
32 | /**
33 | * @author Gilmar P.S.L.
34 | *
35 | * @param
36 | */
37 | public interface FixedField extends Field, FixedLength{
38 |
39 | /**
40 | * @return the filler
41 | */
42 | public abstract Filler getFiller();
43 |
44 | /**
45 | * @param filler the filler to set
46 | */
47 | public abstract void setFiller(Filler filler);
48 | }
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/FixedLength.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type;
30 |
31 | /**
32 | * @author Gilmar P.S.L.
33 | *
34 | */
35 | public interface FixedLength extends Fixed{
36 |
37 | public Integer getFixedLength();
38 |
39 | public boolean isTruncate();
40 |
41 | public void setTruncate(boolean truncate);
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/FixedSize.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type;
30 |
31 | /**
32 | * @author Gilmar P.S.L.
33 | *
34 | */
35 | public interface FixedSize extends Fixed{
36 |
37 | public Integer getFixedSize();
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/component/BlockOfFields.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type.component;
30 |
31 | import static java.lang.String.format;
32 | import static org.jrimum.utilix.Objects.isNotNull;
33 |
34 | import org.jrimum.texgit.type.AbstractStringOfFields;
35 | import org.jrimum.texgit.type.FixedLength;
36 | import org.jrimum.texgit.type.FixedSize;
37 | import org.jrimum.utilix.Collections;
38 | import org.jrimum.utilix.Objects;
39 |
40 | /**
41 | * @author Gilmar P.S.L.
42 | *
43 | */
44 | @SuppressWarnings("serial")
45 | public class BlockOfFields extends AbstractStringOfFields> implements FixedSize, FixedLength{
46 |
47 | /**
48 | * Definição
49 | */
50 | private Integer length;
51 |
52 | /**
53 | * Definição
54 | */
55 | private Integer size;
56 |
57 | /**
58 | *
59 | * Tamanho da string de escrita do bloco.
60 | *
61 | */
62 | private Integer instantLength;
63 |
64 | /**
65 | *
66 | * Ao ultrapassar o tamanho, define se pode truncar ou se dispara uma exceção.
67 | *
68 | */
69 | private boolean truncate;
70 |
71 | /**
72 | *
73 | */
74 | public BlockOfFields() {
75 | super();
76 | }
77 |
78 | /**
79 | * @param length
80 | * @param size
81 | */
82 | public BlockOfFields(Integer length, Integer size) {
83 |
84 | super(size);
85 |
86 | Objects.checkNotNull(length, "length");
87 |
88 | if (length > 0) {
89 |
90 | setLength(length);
91 | setSize(size);
92 |
93 | } else
94 | throw new IllegalArgumentException(format("O comprimento do bloco [%s] deve ser um número natural > 0!", length));
95 | }
96 |
97 | @Override
98 | public BlockOfFields clone() throws CloneNotSupportedException {
99 |
100 | return(BlockOfFields) super.clone();
101 | }
102 |
103 | @Override
104 | public void read(String lineOfFields) {
105 |
106 | Objects.checkNotNull(lineOfFields, "String de leitura nula!");
107 |
108 | Objects.checkNotNull(getFields(), "Fields == null");
109 | Collections.checkNotEmpty(getFields(), "Coleção de fields vazia!");
110 |
111 | if (isSizeAsDefinaed() && isLengthWithDefinaed(lineOfFields.length())) {
112 |
113 | StringBuilder builder = new StringBuilder(lineOfFields);
114 |
115 | for (FixedField> field : getFields()) {
116 |
117 | try {
118 |
119 | field.read(builder.substring(0, field.getFixedLength()));
120 | builder.delete(0, field.getFixedLength());
121 |
122 | } catch (Exception e) {
123 |
124 | throw new IllegalStateException(
125 | format(
126 | "Erro ao tentar ler o campo \"%s\" na posição [%s] no layout do registro.",
127 | field.getName(), getFields().indexOf(field)+1),e);
128 | }
129 | }
130 |
131 | builder = null;
132 | }
133 | }
134 |
135 | @Override
136 | public String write() {
137 |
138 | Objects.checkNotNull(getFields(), "Fields == null");
139 | Collections.checkNotEmpty(getFields(), "Coleção de fields vazia!");
140 |
141 | String str = null;
142 |
143 | isSizeAsDefinaed();
144 |
145 | str = super.write();
146 |
147 | instantLength = str.length();
148 |
149 | if (isTruncate() && instantLength > getFixedLength()) {
150 | str = str.substring(0, getFixedLength());
151 | instantLength = getFixedLength();
152 | }
153 |
154 | isFixedAsDefined();
155 |
156 | return str;
157 | }
158 |
159 | public boolean isFixedAsDefined() throws IllegalStateException {
160 |
161 | return (isSizeAsDefinaed() && isLengthWithDefinaed());
162 | }
163 |
164 | private boolean isLengthWithDefinaed(){
165 |
166 | return isLengthWithDefinaed(instantLength);
167 | }
168 |
169 | private boolean isLengthWithDefinaed(int length){
170 |
171 | if(length == getFixedLength())
172 | return true;
173 | else
174 | throw new IllegalStateException(format("O comprimento da string [%s] é incompátivel com o definido [%s] no layout do registro!",length,getFixedLength()));
175 | }
176 |
177 | private boolean isSizeAsDefinaed(){
178 |
179 | if(size() == getFixedSize())
180 | return true;
181 | else
182 | throw new IllegalStateException(format("O número de fields [%s] é incompátivel com o definido [%s]!", size(), getFixedSize()));
183 | }
184 |
185 | /**
186 | * @return the length
187 | */
188 | public Integer getFixedLength() {
189 | return length;
190 | }
191 |
192 | /**
193 | * @param length the length to set
194 | */
195 | protected void setLength(Integer length) {
196 |
197 | if (isNotNull(length))
198 | this.length = length;
199 | else
200 | throw new IllegalArgumentException(format("Comprimento inválido [%s]!", length));
201 | }
202 |
203 | /**
204 | * @return the size
205 | */
206 | public Integer getFixedSize() {
207 | return size;
208 | }
209 |
210 | /**
211 | * @param size the size to set
212 | */
213 | protected void setSize(Integer size) {
214 |
215 | if (isNotNull(size))
216 | this.size = size;
217 | else
218 | throw new IllegalArgumentException(format("Tamanho inválido [%s]!", size));
219 | }
220 |
221 | public boolean isTruncate() {
222 | return this.truncate;
223 | }
224 |
225 | public void setTruncate(boolean truncate) {
226 | this.truncate = truncate;
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/component/Filler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 30/03/2008 - 18:17:00
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 30/03/2008 - 18:17:00
27 | *
28 | */
29 | package org.jrimum.texgit.type.component;
30 |
31 | import static java.lang.String.format;
32 | import static org.apache.commons.lang.StringUtils.EMPTY;
33 | import static org.jrimum.utilix.Objects.isNotNull;
34 |
35 | import org.apache.commons.lang.StringUtils;
36 | import org.jrimum.texgit.TextStream;
37 | import org.jrimum.utilix.Objects;
38 |
39 | /**
40 | *
41 | * Preenchedor de caracteres genérico. É utilizado para preencher objetos String
,
42 | * tanto da esquerda para a direita como da direita para esquerda, com o objeto genérico até
43 | * o tamanho especificado. Caso o tamanho especificado seja menor
44 | * ou igual a 0 (ZERO), este valor será desconsiderado e nada será preenchido.
45 | *
46 | *
47 | * É utilizado o método toString()
do objeto preenchedor.
48 | *
49 | *
50 | * Exemplo:
51 | *
52 | * Filler filler = new Filler(new Integer(10), SideToFill.LEFT);
53 | * String outPut = filler.fill("TESTE", 8);
54 | *
55 | * outPut -> "101TESTE"
56 | *
57 | *
58 | * @author Gilmar P.S.L
59 | * @author Misael Barreto
60 | * @author Rômulo Augusto
61 | * @author Nordeste Fomento
62 | * Mercantil
63 | *
64 | * @since JRimum 0.1
65 | *
66 | * @version 0.2.1-inc
67 | *
68 | */
69 | @SuppressWarnings("serial")
70 | public class Filler implements org.jrimum.texgit.type.Filler{
71 |
72 | private G padding;
73 |
74 | private Side sideToFill;
75 |
76 | public Filler() {
77 | super();
78 | }
79 |
80 | /**
81 | * @param fillWith
82 | */
83 | public Filler(G fillWith) {
84 |
85 | setPadding(fillWith);
86 | setSideToFill(Side.LEFT);
87 | }
88 |
89 | /**
90 | * @param fillWith
91 | * @param sideToFill
92 | */
93 | public Filler(G fillWith, Side sideToFill) {
94 |
95 | setPadding(fillWith);
96 | setSideToFill(sideToFill);
97 | }
98 |
99 | /**
100 | * @see org.jrimum.texgit.type#getPadding()
101 | */
102 | public G getPadding() {
103 | return padding;
104 | }
105 |
106 | /**
107 | * @see org.jrimum.texgit.type#setPadding(G)
108 | */
109 | public void setPadding(G fillWith) {
110 |
111 | if(isNotNull(fillWith)){
112 | this.padding = fillWith;
113 | }else{
114 | throw new IllegalArgumentException(format("Preenchimento inválido [%s]!",fillWith));
115 | }
116 | }
117 |
118 | /**
119 | * @see org.jrimum.texgit.type#getSideToFill()
120 | */
121 | public Side getSideToFill() {
122 | return sideToFill;
123 | }
124 |
125 | /**
126 | * @see org.jrimum.texgit.type#setSideToFill(org.jrimum.texgit.type.component.Side)
127 | */
128 | public void setSideToFill(Side sideToFill) {
129 |
130 | if(isNotNull(sideToFill)){
131 | this.sideToFill = sideToFill;
132 | }else{
133 | throw new IllegalArgumentException(format("Lado para preenchimento [%s]!",sideToFill));
134 | }
135 | }
136 |
137 | /**
138 | * @see org.jrimum.texgit.type#fill(java.lang.String, int)
139 | */
140 | public String fill(String toFill, int length){
141 |
142 | String str = null;
143 |
144 | switch(sideToFill){
145 |
146 | case LEFT:
147 | str = fillLeft(toFill, length);
148 | break;
149 |
150 | case RIGHT:
151 | str = fillRight(toFill, length);
152 | break;
153 | }
154 |
155 | return str;
156 | }
157 |
158 | /**
159 | * @see org.jrimum.texgit.type#fill(long, int)
160 | */
161 | public String fill(long tofill, int length){
162 | return fill(String.valueOf(tofill), length);
163 | }
164 |
165 | /**
166 | * @see org.jrimum.texgit.type#fill(int, int)
167 | */
168 | public String fill(int tofill, int length){
169 | return fill(String.valueOf(tofill), length);
170 | }
171 |
172 | /**
173 | * @see org.jrimum.texgit.type#fill(short, int)
174 | */
175 | public String fill(short tofill, int length){
176 | return fill(String.valueOf(tofill), length);
177 | }
178 |
179 | /**
180 | * @see org.jrimum.texgit.type#fill(byte, int)
181 | */
182 | public String fill(byte tofill, int length){
183 | return fill(String.valueOf(tofill), length);
184 | }
185 |
186 | /**
187 | * @see org.jrimum.texgit.type#fill(char, int)
188 | */
189 | public String fill(char tofill, int length){
190 | return fill(String.valueOf(tofill), length);
191 | }
192 |
193 | /**
194 | * @see org.jrimum.texgit.type#fill(double, int)
195 | */
196 | public String fill(double tofill, int length){
197 | return fill(String.valueOf(tofill), length);
198 | }
199 |
200 | /**
201 | * @see org.jrimum.texgit.type#fill(float, int)
202 | */
203 | public String fill(float tofill, int length){
204 | return fill(String.valueOf(tofill), length);
205 | }
206 |
207 | /**
208 | * @see org.jrimum.texgit.type#fill(java.lang.Object, int)
209 | */
210 | public String fill(Object tofill, int length){
211 |
212 | String toFillTemp = null;
213 |
214 | if(isNotNull(tofill)){
215 | toFillTemp = tofill.toString();
216 | }
217 |
218 | return fill(toFillTemp, length);
219 | }
220 |
221 | /**
222 | * @see org.jrimum.texgit.type#fill(org.jrimum.texgit.TextStream, int)
223 | */
224 | public String fill(TextStream tofill, int length){
225 |
226 | String toFillTemp = null;
227 |
228 | if(isNotNull(tofill)){
229 | toFillTemp = tofill.write();
230 | }
231 |
232 | return fill(toFillTemp, length);
233 | }
234 |
235 | /**
236 | * @param toFill
237 | * @param length
238 | * @return String preenchida
239 | */
240 | private String fillRight(String toFill, int length) {
241 |
242 | return StringUtils.rightPad(toFill, length, padding.toString());
243 | }
244 |
245 | /**
246 | * @param toFill
247 | * @param length
248 | * @return String preenchida
249 | */
250 | private String fillLeft(String toFill, int length) {
251 |
252 | return StringUtils.leftPad(toFill, length, padding.toString());
253 | }
254 |
255 | @Override
256 | public String toString() {
257 |
258 | return format(
259 | "Filler [padding=\"%s\", sideToFill=%s]"
260 | , Objects.whenNull(this.padding, EMPTY)
261 | , Objects.whenNull(this.sideToFill, EMPTY));
262 | }
263 |
264 | }
265 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/component/Fillers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type.component;
30 |
31 | import org.jrimum.texgit.TextStream;
32 | import org.jrimum.utilix.text.Strings;
33 |
34 |
35 | /**
36 | * @author Gilmar P.S.L.
37 | *
38 | */
39 | public enum Fillers implements org.jrimum.texgit.type.Filler{
40 |
41 | /**
42 | * Filler padrão para preenchimento com zeros a esquerda.
43 | */
44 | ZERO_LEFT(new Filler(0, Side.LEFT)),
45 |
46 | /**
47 | * Filler padrão para preenchimento com zeros a direita.
48 | */
49 | ZERO_RIGHT(new Filler(0, Side.RIGHT)),
50 |
51 | /**
52 | * Filler padrão para preenchimento com espaços em branco a esquerda.
53 | */
54 | WHITE_SPACE_LEFT(new Filler(Strings.WHITE_SPACE, Side.LEFT)),
55 |
56 | /**
57 | * Filler padrão para preenchimento com espaços em branco a direita.
58 | */
59 | WHITE_SPACE_RIGHT(new Filler(Strings.WHITE_SPACE, Side.RIGHT));
60 |
61 | private Filler> filler;
62 |
63 | private Fillers(Filler> filler){
64 | this.filler = filler;
65 | }
66 |
67 | /**
68 | * @param toFill
69 | * @param length
70 | * @return String preenchida
71 | * @see org.jrimum.texgit.type.component.Filler#fill(java.lang.String, int)
72 | */
73 | public String fill(String toFill, int length) {
74 | return filler.fill(toFill, length);
75 | }
76 |
77 | /**
78 | * @param tofill
79 | * @param length
80 | * @return String preenchida
81 | * @see org.jrimum.texgit.type.component.Filler#fill(long, int)
82 | */
83 | public String fill(long tofill, int length) {
84 | return filler.fill(tofill, length);
85 | }
86 |
87 | /**
88 | * @param tofill
89 | * @param length
90 | * @return String preenchida
91 | * @see org.jrimum.texgit.type.component.Filler#fill(int, int)
92 | */
93 | public String fill(int tofill, int length) {
94 | return filler.fill(tofill, length);
95 | }
96 |
97 | /**
98 | * @param tofill
99 | * @param length
100 | * @return String preenchida
101 | * @see org.jrimum.texgit.type.component.Filler#fill(short, int)
102 | */
103 | public String fill(short tofill, int length) {
104 | return filler.fill(tofill, length);
105 | }
106 |
107 | /**
108 | * @param tofill
109 | * @param length
110 | * @return String preenchida
111 | * @see org.jrimum.texgit.type.component.Filler#fill(byte, int)
112 | */
113 | public String fill(byte tofill, int length) {
114 | return filler.fill(tofill, length);
115 | }
116 |
117 | /**
118 | * @param tofill
119 | * @param length
120 | * @return String preenchida
121 | * @see org.jrimum.texgit.type.component.Filler#fill(char, int)
122 | */
123 | public String fill(char tofill, int length) {
124 | return filler.fill(tofill, length);
125 | }
126 |
127 | /**
128 | * @param tofill
129 | * @param length
130 | * @return String preenchida
131 | * @see org.jrimum.texgit.type.component.Filler#fill(double, int)
132 | */
133 | public String fill(double tofill, int length) {
134 | return filler.fill(tofill, length);
135 | }
136 |
137 | /**
138 | * @param tofill
139 | * @param length
140 | * @return String preenchida
141 | * @see org.jrimum.texgit.type.component.Filler#fill(float, int)
142 | */
143 | public String fill(float tofill, int length) {
144 | return filler.fill(tofill, length);
145 | }
146 |
147 | /**
148 | * @param tofill
149 | * @param length
150 | * @return String preenchida
151 | * @see org.jrimum.texgit.type.component.Filler#fill(java.lang.Object, int)
152 | */
153 | public String fill(Object tofill, int length) {
154 | return filler.fill(tofill, length);
155 | }
156 |
157 | /**
158 | * @param tofill
159 | * @param length
160 | * @return String preenchida
161 | * @see org.jrimum.texgit.type.component.Filler#fill(org.jrimum.texgit.TextStream, int)
162 | */
163 | public String fill(TextStream tofill, int length) {
164 | return filler.fill(tofill, length);
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/component/FixedField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type.component;
30 |
31 | import static java.lang.String.format;
32 | import static org.apache.commons.lang.StringUtils.EMPTY;
33 | import static org.jrimum.utilix.Objects.isNotNull;
34 |
35 | import java.text.Format;
36 |
37 | import org.jrimum.texgit.type.Filler;
38 | import org.jrimum.utilix.Objects;
39 |
40 |
41 | /**
42 | * @author Gilmar P.S.L.
43 | *
44 | * @param
45 | */
46 | @SuppressWarnings("serial")
47 | public class FixedField extends Field implements org.jrimum.texgit.type.FixedField{
48 |
49 | /**
50 | *
51 | * Tamanho de especificação e parâmetro da string de leitura ou escrita do campo.
52 | *
53 | */
54 | private Integer length;
55 |
56 | /**
57 | *
58 | * Preenchedor do valor utilizado na hora da escrita.
59 | *
60 | */
61 | private Filler filler;
62 |
63 |
64 | /**
65 | *
66 | * Tamanho da string de escrita do campo.
67 | *
68 | */
69 | private Integer instantLength;
70 |
71 | /**
72 | *
73 | * Ao ultrapassar o tamanho, define se pode truncar ou se dispara uma exceção.
74 | *
75 | */
76 | private boolean truncate;
77 |
78 |
79 | /**
80 | *
81 | */
82 | public FixedField() {
83 | super();
84 | }
85 |
86 | public FixedField(G value, Integer length) {
87 | super(value);
88 | setFixedLength(length);
89 | }
90 |
91 | public FixedField(G value, Integer length, Filler filler) {
92 | super(value);
93 | setFixedLength(length);
94 | setFiller(filler);
95 | }
96 |
97 | public FixedField(G value, Integer length, Format formatter) {
98 | super(value,formatter);
99 | setFixedLength(length);
100 | }
101 |
102 | public FixedField(G value, Integer length, Format formatter, Filler filler) {
103 | super(value,formatter);
104 | setFixedLength(length);
105 | setFiller(filler);
106 | }
107 |
108 | public FixedField(String name, G value, Integer length) {
109 | super(name,value);
110 | setFixedLength(length);
111 | }
112 |
113 | public FixedField(String name, G value, Integer length, Filler filler) {
114 | super(name,value);
115 | setFixedLength(length);
116 | setFiller(filler);
117 | }
118 |
119 | public FixedField(String name, G value, Integer length, Format formatter) {
120 | super(name,value,formatter);
121 | setFixedLength(length);
122 | }
123 |
124 | public FixedField(String name, G value, Integer length, Format formatter, Filler filler) {
125 | super(name,value,formatter);
126 | setFixedLength(length);
127 | setFiller(filler);
128 | }
129 |
130 | @Override
131 | public FixedField clone() throws CloneNotSupportedException {
132 |
133 | return (FixedField) super.clone();
134 | }
135 |
136 | /**
137 | * @see org.jrimum.texgit.type.component.Field#read(java.lang.String)
138 | */
139 | @Override
140 | public void read(String str) {
141 |
142 | Objects.checkNotNull(str, "String inválida [null]!");
143 |
144 | if (str.length() == getFixedLength()) {
145 | super.read(str);
146 | } else
147 | throw new IllegalArgumentException(format("Tamanho da string [%s] diferente do especificado [%s]! %s",str.length(),getFixedLength(),toString()));
148 | }
149 |
150 | /**
151 | * @see org.jrimum.texgit.type.component.Field#write()
152 | */
153 | @Override
154 | public String write() {
155 |
156 | String str = fill(super.write());
157 |
158 | instantLength = str.length();
159 |
160 | if (isTruncate() && instantLength > getFixedLength()) {
161 | str = str.substring(0, getFixedLength());
162 | instantLength = getFixedLength();
163 | }
164 |
165 | isFixedAsDefined();
166 |
167 | return str;
168 | }
169 |
170 | private String fill(String str) {
171 |
172 | if(isNotNull(filler))
173 | str = filler.fill(str, length);
174 |
175 | return str;
176 | }
177 |
178 | public boolean isFixedAsDefined() throws IllegalStateException {
179 |
180 | if(instantLength.equals(getFixedLength()))
181 | return true;
182 | else
183 | throw new IllegalStateException(format("Tamanho da string [%s] diferente do especificado [%s]! %s",instantLength,getFixedLength(),toString()));
184 | }
185 |
186 | public Integer getFixedLength() {
187 |
188 | return this.length;
189 | }
190 |
191 | public void setFixedLength(Integer length) {
192 |
193 | if (isNotNull(length) && length.intValue() > 0)
194 | this.length = length;
195 | else
196 | throw new IllegalArgumentException(format("Comprimento inválido [%s]!",length));
197 |
198 | }
199 |
200 | public Filler getFiller() {
201 | return filler;
202 | }
203 |
204 | public void setFiller(Filler filler) {
205 |
206 | if(isNotNull(filler))
207 | this.filler = filler;
208 | else
209 | throw new IllegalArgumentException(format("Preenchedor inválido [%s]!",filler));
210 | }
211 |
212 | public boolean isTruncate() {
213 | return this.truncate;
214 | }
215 |
216 | public void setTruncate(boolean truncate) {
217 | this.truncate = truncate;
218 | }
219 |
220 |
221 | @Override
222 | public String toString() {
223 |
224 | return format(
225 | "%s FixedField [length=%s, instantLength=%s, filler=%s, truncate=%s]",
226 | super.toString()
227 | , Objects.whenNull(this.length, EMPTY)
228 | , Objects.whenNull(this.instantLength, EMPTY)
229 | , Objects.whenNull(this.filler, EMPTY)
230 | , Objects.whenNull(this.truncate, EMPTY));
231 | }
232 |
233 | }
234 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/component/FlatFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type.component;
30 |
31 | import static java.lang.String.format;
32 | import static org.apache.commons.lang.StringUtils.EMPTY;
33 | import static org.apache.commons.lang.StringUtils.isNotBlank;
34 | import static org.jrimum.utilix.Objects.isNotNull;
35 | import static org.jrimum.utilix.Objects.isNull;
36 |
37 | import java.util.ArrayList;
38 | import java.util.Collection;
39 | import java.util.List;
40 | import java.util.Set;
41 |
42 |
43 | /**
44 | * @author Gilmar P.S.L.
45 | *
46 | */
47 | @SuppressWarnings("serial")
48 | public class FlatFile implements org.jrimum.texgit.FlatFile{
49 |
50 | private List records;
51 |
52 | private Set repitablesRecords;
53 |
54 | private List recordsOrder;
55 |
56 | private RecordFactory recordFactory;
57 |
58 | public FlatFile(RecordFactory iFac4Rec) {
59 |
60 | this.recordFactory = iFac4Rec;
61 | this.records = new ArrayList();
62 | }
63 |
64 | public Record getRecord(String idName){
65 |
66 | Record record = null;
67 |
68 | if (isNotBlank(idName)) {
69 | if (!isRepitable(idName)){
70 | if (!records.isEmpty()) {
71 | for (Record rec : records) {
72 | if (idName.equals(rec.getName()))
73 | record = rec;
74 | }
75 | }
76 | }
77 | }
78 |
79 | return record;
80 | }
81 |
82 | public boolean isRepitable(String idName){
83 |
84 | return (isNotNull(repitablesRecords) && !repitablesRecords.isEmpty() && repitablesRecords.contains(idName));
85 | }
86 |
87 | public org.jrimum.texgit.Record createRecord(String idName){
88 |
89 | return recordFactory.create(idName);
90 | }
91 |
92 | public void addRecord(Record record){
93 |
94 | if(isNotNull(record))
95 | if(isMyRecord(record.getName()))
96 | records.add(record);
97 | else
98 | throw new IllegalArgumentException("Record fora de scopo!");
99 | }
100 |
101 | public boolean isMyRecord(String idName){
102 | boolean is = false;
103 |
104 | if (isNotBlank(idName)) {
105 | if(!recordsOrder.isEmpty())
106 | if(recordsOrder.contains(idName))
107 | is = true;
108 | }
109 | return is;
110 | }
111 |
112 | public void read(List str) {
113 |
114 | if(isNotNull(str)){
115 | if(!str.isEmpty()){
116 |
117 | String line = null;
118 | int lineIndex = 0;
119 |
120 | FixedField typeRecord = null;
121 | Record record = null;
122 |
123 | for(String id : recordsOrder){
124 |
125 | record = recordFactory.create(id);
126 |
127 | try{
128 |
129 | if(isRepitable(id)){
130 |
131 | boolean read = true;
132 |
133 | while(read){
134 |
135 | if(isNull(record))
136 | record = recordFactory.create(id);
137 |
138 | if(lineIndex < str.size())
139 | line = str.get(lineIndex);
140 |
141 | typeRecord = record.readID(line);
142 |
143 | read = record.getIdType().getValue().equals(typeRecord.getValue()) && (lineIndex < str.size());
144 |
145 | if(read){
146 |
147 | record.read(line);
148 | lineIndex++;
149 | addRecord(record);
150 |
151 | if(record.isHeadOfGroup()){
152 | lineIndex = record.readInnerRecords(str,lineIndex,recordFactory);
153 | }
154 |
155 | record = null;
156 | }
157 | }
158 |
159 | }else{
160 | if((lineIndex < str.size())){
161 |
162 | line = str.get(lineIndex);
163 | typeRecord = record.readID(line);
164 |
165 | if(record.getIdType().getValue().equals(typeRecord.getValue())){
166 |
167 | record.read(line);
168 | lineIndex++;
169 | addRecord(record);
170 |
171 | if(record.isHeadOfGroup()){
172 | lineIndex = record.readInnerRecords(str,lineIndex,recordFactory);
173 | }
174 |
175 | record = null;
176 | }
177 | }
178 | }
179 |
180 | } catch (Exception e) {
181 |
182 | throw new IllegalStateException(format(
183 | "Erro ao tentar ler o registro \"%s\".", record.getName()), e);
184 | }
185 | }
186 | }
187 | }
188 | }
189 |
190 | public List write() {
191 |
192 | return write(EMPTY);
193 | }
194 |
195 | public List write(String lineEnding) {
196 |
197 | ArrayList out = new ArrayList(records.size());
198 |
199 | for(String id : recordsOrder){
200 |
201 | if(isRepitable(id)){
202 |
203 | Record rec = null;
204 |
205 | for(org.jrimum.texgit.Record record : getRecords(id)){
206 |
207 | rec = Record.class.cast(record);
208 |
209 | try{
210 |
211 | out.add(rec.write()+lineEnding);
212 |
213 | } catch (Exception e) {
214 |
215 | throw new IllegalStateException(format(
216 | "Erro ao tentar escrever o registro \"%s\".", rec.getName()), e);
217 | }
218 |
219 | if(rec.isHeadOfGroup() && rec.hasInnerRecords()){
220 | out.addAll(rec.writeInnerRecords(lineEnding));
221 | }
222 | }
223 |
224 | }else{
225 |
226 | Record rec = getRecord(id);
227 |
228 | try{
229 |
230 | out.add(rec.write()+lineEnding);
231 |
232 | } catch (Exception e) {
233 |
234 | throw new IllegalStateException(format(
235 | "Erro ao tentar escrever o registro \"%s\".", rec.getName()), e);
236 | }
237 |
238 | if(rec.isHeadOfGroup() && rec.hasInnerRecords()){
239 | out.addAll(rec.writeInnerRecords(lineEnding));
240 | }
241 | }
242 | }
243 |
244 | return out;
245 | }
246 |
247 | public org.jrimum.texgit.FlatFile addRecord(org.jrimum.texgit.Record record) {
248 |
249 | if(isNotNull(record)){
250 | Record rec = Record.class.cast(record);
251 | addRecord(rec);
252 | }
253 |
254 | return this;
255 | }
256 |
257 | public Collection getRecords(String idName) {
258 |
259 | List secRecords = new ArrayList();
260 |
261 | if (isNotBlank(idName)) {
262 | if (isRepitable(idName)) {
263 | if (!records.isEmpty()) {
264 | for (Record rec : records) {
265 | if (idName.equals(rec.getName()))
266 | secRecords.add(rec);
267 | }
268 | }
269 | }
270 | }
271 |
272 | return secRecords;
273 | }
274 |
275 | public org.jrimum.texgit.FlatFile addAllRecords(Collection records) {
276 | // TODO IMPLEMENTAR
277 | throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
278 | }
279 |
280 | public org.jrimum.texgit.FlatFile addRecords(String idName, Collection records) {
281 | // TODO IMPLEMENTAR
282 | throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
283 | }
284 |
285 | public Collection getAllRecords() {
286 | // TODO IMPLEMENTAR
287 | throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
288 | }
289 |
290 | public org.jrimum.texgit.Record removeRecord(String idName) {
291 | // TODO IMPLEMENTAR
292 | throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
293 | }
294 |
295 | public org.jrimum.texgit.FlatFile setAllRecords(Collection records) {
296 | // TODO IMPLEMENTAR
297 | throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
298 | }
299 |
300 | public org.jrimum.texgit.FlatFile setRecords(String idName, Collection records) {
301 | // TODO IMPLEMENTAR
302 | throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
303 | }
304 |
305 | public Set getRepitablesRecords() {
306 | return repitablesRecords;
307 | }
308 |
309 | public void setRepitablesRecords(Set repitablesRecords) {
310 | this.repitablesRecords = repitablesRecords;
311 | }
312 |
313 | public List getRecordsOrder() {
314 | return recordsOrder;
315 | }
316 |
317 | public void setRecordsOrder(List recordsOrder) {
318 | this.recordsOrder = recordsOrder;
319 | }
320 |
321 | }
322 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/component/RecordFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 26/07/2008 - 12:44:41
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 26/07/2008 - 12:44:41
27 | *
28 | */
29 | package org.jrimum.texgit.type.component;
30 |
31 | import org.jrimum.texgit.Record;
32 |
33 | /**
34 | * @author Gilmar P.S.L.
35 | *
36 | * @param
37 | */
38 | public interface RecordFactory {
39 |
40 | public abstract G create(String name);
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/jrimum/texgit/type/component/Side.java:
--------------------------------------------------------------------------------
1 | package org.jrimum.texgit.type.component;
2 |
3 | /**
4 | * Lados para alinhar campos, preenchimento ou orientações em geral.
5 | *
6 | * @author Gilmar P.S.L.
7 | */
8 | public enum Side {
9 |
10 | LEFT,
11 |
12 | RIGHT;
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/java/org/jrimum/texgit/type/component/TestFiller.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 30/03/2008 - 18:15:42
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 30/03/2008 - 18:15:42
27 | *
28 | */
29 |
30 | package org.jrimum.texgit.type.component;
31 |
32 | import static org.junit.Assert.assertEquals;
33 | import static org.junit.Assert.assertTrue;
34 |
35 | import org.jrimum.texgit.TextStream;
36 | import org.jrimum.texgit.type.component.Filler;
37 | import org.jrimum.utilix.text.Strings;
38 | import org.junit.Before;
39 | import org.junit.Test;
40 |
41 | /**
42 | *
43 | * Teste unitário para a classe Filler
.
44 | *
45 | *
46 | * @author Gilmar P.S.L.
47 | * @author Rômulo Augusto
48 | *
49 | * @since 0.2
50 | *
51 | * @version 0.2
52 | */
53 | public class TestFiller {
54 |
55 | private static final String CAMPO = "TESTE";
56 |
57 | private static final int TAMANHO = 10;
58 |
59 | private Filler fillerString;
60 | private Filler fillerInteger;
61 | private Filler fillerDouble;
62 | private Filler fillerSide;
63 | private Filler whiteSpaceLeft;
64 | private Filler zeroLeft ;
65 | private Filler zeroRight;
66 |
67 | @Before
68 | public void setup(){
69 | whiteSpaceLeft = new Filler(Strings.WHITE_SPACE, Side.LEFT);
70 | zeroLeft = new Filler(0, Side.LEFT);
71 | zeroRight = new Filler(0, Side.RIGHT);
72 | }
73 |
74 | @Test(expected = IllegalArgumentException.class)
75 | public void testSetSideNullValue() {
76 |
77 | whiteSpaceLeft.setSideToFill(null);
78 | }
79 |
80 | @Test(expected = IllegalArgumentException.class)
81 | public void testSetToFillNullValue() {
82 |
83 | whiteSpaceLeft.setPadding(null);
84 | }
85 |
86 | @Test
87 | public void testSetToFill() {
88 |
89 | whiteSpaceLeft.setPadding(CAMPO);
90 |
91 | assertTrue(whiteSpaceLeft.getPadding() instanceof String);
92 | assertEquals(whiteSpaceLeft.getPadding(), CAMPO);
93 | }
94 |
95 | @Test
96 | public void testSetSide() {
97 |
98 | whiteSpaceLeft.setSideToFill(Side.RIGHT);
99 |
100 | assertEquals(whiteSpaceLeft.getSideToFill(), Side.RIGHT);
101 | }
102 |
103 | @Test(expected = IllegalArgumentException.class)
104 | public void testFiller() {
105 |
106 | new Filler(null, null);
107 | new Filler("", null);
108 | new Filler(null, Side.LEFT);
109 | }
110 |
111 | @Test
112 | public void testFillString() {
113 |
114 | assertEquals(CAMPO + "00000", zeroRight.fill(CAMPO, TAMANHO));
115 | assertEquals("00000" + CAMPO, zeroLeft.fill(CAMPO, TAMANHO));
116 | }
117 |
118 | @Test
119 | public void testFillLong() {
120 |
121 | assertEquals(1L + "000000000", zeroRight.fill(1L, TAMANHO));
122 | assertEquals("000000000" + 1L, zeroLeft.fill(1L, TAMANHO));
123 | }
124 |
125 | @Test
126 | public void testFillInt() {
127 |
128 | assertEquals(1 + "000000000", zeroRight.fill(1, TAMANHO));
129 | assertEquals("000000000" + 1, zeroLeft.fill(1, TAMANHO));
130 | }
131 |
132 | @Test
133 | public void testFillShort() {
134 |
135 | assertEquals((short) 1 + "000000000", zeroRight.fill((short) 1,
136 | TAMANHO));
137 | assertEquals("000000000" + (short) 1, zeroLeft.fill((short) 1,
138 | TAMANHO));
139 | }
140 |
141 | @Test
142 | public void testFillByte() {
143 |
144 | assertEquals((byte) 1 + "000000000", zeroRight.fill((byte) 1,
145 | TAMANHO));
146 | assertEquals("000000000" + (byte) 1, zeroLeft.fill((byte) 1,
147 | TAMANHO));
148 | }
149 |
150 | @Test
151 | public void testFillChar() {
152 |
153 | assertEquals('1' + "000000000", zeroRight.fill('1', TAMANHO));
154 | assertEquals("000000000" + '1', zeroLeft.fill('1', TAMANHO));
155 | }
156 |
157 | @Test
158 | public void testFillDouble() {
159 |
160 | assertEquals(1.0 + "0000000", zeroRight.fill(1.0, TAMANHO));
161 | assertEquals("0000000" + 1.0, zeroLeft.fill(1.0, TAMANHO));
162 | }
163 |
164 | @Test
165 | public void testFillFloat() {
166 |
167 | assertEquals(1.0f + "0000000", zeroRight.fill(1.0f, TAMANHO));
168 | assertEquals("0000000" + 1.0f, zeroLeft.fill(1.0f, TAMANHO));
169 | }
170 |
171 | @Test
172 | public void testFillObject() {
173 |
174 | Object object = new Object() {
175 |
176 | @Override
177 | public String toString() {
178 | return CAMPO;
179 | }
180 | };
181 |
182 | assertEquals(object + "00000", zeroRight.fill(object, TAMANHO));
183 | assertEquals("00000" + object, zeroLeft.fill(object, TAMANHO));
184 | }
185 |
186 | @Test
187 | public void testFillITextStream() {
188 |
189 | TextStream textStream = new TextStream() {
190 |
191 | private static final long serialVersionUID = 1L;
192 |
193 | public void read(String g) {
194 | }
195 |
196 | public String write() {
197 |
198 | return CAMPO;
199 | }
200 | };
201 |
202 | assertEquals(textStream.write() + "00000", zeroRight.fill(
203 | textStream, TAMANHO));
204 | assertEquals("00000" + textStream.write(), zeroLeft.fill(
205 | textStream, TAMANHO));
206 | }
207 |
208 | @Test
209 | public void testFill() {
210 |
211 | fillerString = new Filler("ABC", Side.LEFT);
212 | assertTrue(fillerString.getPadding() instanceof String);
213 | assertEquals("ABCAB" + CAMPO, fillerString.fill(CAMPO, TAMANHO));
214 | assertEquals(CAMPO, fillerString.fill(CAMPO, 0));
215 | assertEquals(CAMPO, fillerString.fill(CAMPO, -TAMANHO));
216 |
217 | fillerString.setSideToFill(Side.RIGHT);
218 | assertEquals(CAMPO + "ABCAB", fillerString.fill(CAMPO, TAMANHO));
219 | assertEquals(CAMPO, fillerString.fill(CAMPO, 0));
220 | assertEquals(CAMPO, fillerString.fill(CAMPO, -TAMANHO));
221 |
222 | fillerInteger = new Filler(new Integer(TAMANHO),
223 | Side.LEFT);
224 | assertTrue(fillerInteger.getPadding() instanceof Integer);
225 | assertEquals("10101" + CAMPO, fillerInteger.fill(CAMPO, TAMANHO));
226 | assertEquals(CAMPO, fillerInteger.fill(CAMPO, 0));
227 | assertEquals(CAMPO, fillerInteger.fill(CAMPO, -TAMANHO));
228 |
229 | fillerInteger.setSideToFill(Side.RIGHT);
230 | assertEquals(CAMPO + "10101", fillerInteger.fill(CAMPO, TAMANHO));
231 | assertEquals(CAMPO, fillerInteger.fill(CAMPO, 0));
232 | assertEquals(CAMPO, fillerInteger.fill(CAMPO, -TAMANHO));
233 |
234 | fillerDouble = new Filler(new Double(10.9), Side.LEFT);
235 | assertTrue(fillerDouble.getPadding() instanceof Double);
236 | assertEquals("10.91" + CAMPO, fillerDouble.fill(CAMPO, TAMANHO));
237 | assertEquals(CAMPO, fillerDouble.fill(CAMPO, 0));
238 | assertEquals(CAMPO, fillerDouble.fill(CAMPO, -TAMANHO));
239 |
240 | fillerDouble.setSideToFill(Side.RIGHT);
241 | assertEquals(CAMPO + "10.91", fillerDouble.fill(CAMPO, TAMANHO));
242 | assertEquals(CAMPO, fillerDouble.fill(CAMPO, 0));
243 | assertEquals(CAMPO, fillerDouble.fill(CAMPO, -TAMANHO));
244 |
245 | fillerSide = new Filler(Side.LEFT, Side.LEFT);
246 | assertTrue(fillerSide.getPadding() instanceof Side);
247 | assertEquals("LEFTL" + CAMPO, fillerSide.fill(CAMPO, TAMANHO));
248 | assertEquals(CAMPO, fillerSide.fill(CAMPO, 0));
249 | assertEquals(CAMPO, fillerSide.fill(CAMPO, -TAMANHO));
250 |
251 | fillerSide.setSideToFill(Side.RIGHT);
252 | assertEquals(CAMPO + "LEFTL", fillerSide.fill(CAMPO, TAMANHO));
253 | assertEquals(CAMPO, fillerSide.fill(CAMPO, 0));
254 | assertEquals(CAMPO, fillerSide.fill(CAMPO, -TAMANHO));
255 | }
256 |
257 | }
258 |
--------------------------------------------------------------------------------
/src/test/java/org/jrimum/texgit/type/component/TestFixedField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 30/03/2008 - 18:15:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 30/03/2008 - 18:15:56
27 | *
28 | */
29 |
30 | package org.jrimum.texgit.type.component;
31 |
32 | import static org.jrimum.utilix.text.DateFormat.DDMMYYYY_B;
33 | import static org.junit.Assert.assertEquals;
34 | import static org.junit.Assert.assertNotNull;
35 | import static org.junit.Assert.assertTrue;
36 |
37 | import java.math.BigDecimal;
38 | import java.text.DateFormat;
39 | import java.text.Format;
40 | import java.text.SimpleDateFormat;
41 | import java.util.Date;
42 |
43 | import org.apache.commons.lang.StringUtils;
44 | import org.jrimum.utilix.Dates;
45 | import org.jrimum.utilix.text.DecimalFormat;
46 | import org.junit.After;
47 | import org.junit.Before;
48 | import org.junit.Test;
49 |
50 | /**
51 | *
52 | * Teste unitário para a classe utilitária de coleções.
53 | *
54 | *
55 | * @author Gilmar P.S.L.
56 | * @author Rômulo Augusto
57 | *
58 | * @since 0.2
59 | *
60 | * @version 0.2
61 | */
62 | public class TestFixedField {
63 |
64 | private static final DateFormat FORMAT_DDMMYY = new SimpleDateFormat("ddMMyy");
65 |
66 | private FixedField campoString;
67 |
68 | private FixedField campoInteger;
69 |
70 | private FixedField campoLong;
71 |
72 | private FixedField campoDate;
73 |
74 | private FixedField campoDecimal;
75 |
76 | private FixedField campoDecimal_v9;
77 |
78 | @Before
79 | public void setUp() {
80 |
81 | campoString = new FixedField(StringUtils.EMPTY, 8, Fillers.WHITE_SPACE_RIGHT);
82 |
83 | campoDate = new FixedField(DDMMYYYY_B.parse("22/07/2007"), 6, FORMAT_DDMMYY);
84 |
85 | campoInteger = new FixedField(0, 6, Fillers.ZERO_LEFT);
86 |
87 | campoLong = new FixedField(0L, 6, Fillers.ZERO_LEFT);
88 |
89 | campoDecimal = new FixedField(new BigDecimal("875.98"), 11, DecimalFormat.NUMBER_DD_BR.copy(), Fillers.ZERO_LEFT);
90 |
91 | campoDecimal_v9 = new FixedField(new BigDecimal("875.9"), 10, DecimalFormat.NUMBER_D_BR.copy(), Fillers.ZERO_LEFT);
92 | }
93 |
94 | @After
95 | public void tearDown() {
96 |
97 | campoString = null;
98 | campoDate = null;
99 | campoInteger = null;
100 | campoLong = null;
101 | campoDecimal = null;
102 | campoDecimal_v9 = null;
103 | }
104 |
105 | @Test(expected = IllegalArgumentException.class)
106 | public void testCampo() {
107 |
108 | Format format = null;
109 |
110 | campoDate = new FixedField(new Date(), 0, FORMAT_DDMMYY);
111 | campoDate = new FixedField(null, 1, FORMAT_DDMMYY);
112 | campoDate = new FixedField(new Date(), 0, format);
113 | }
114 |
115 | @Test
116 | public void testLer() {
117 |
118 | campoString.read("COBRANCA");
119 | assertNotNull(campoString.getValue());
120 | assertTrue(campoString.getValue() instanceof String);
121 | assertEquals("COBRANCA", campoString.getValue().toString());
122 |
123 | campoDate.read("011002");
124 | assertNotNull(campoDate.getValue());
125 | assertTrue(campoDate.getValue() instanceof Date);
126 | assertEquals("011002", FORMAT_DDMMYY.format(campoDate
127 | .getValue()));
128 |
129 | campoInteger.read("000001");
130 | assertNotNull(campoInteger.getValue());
131 | assertTrue(campoInteger.getValue() instanceof Integer);
132 | assertTrue(new Integer(1).compareTo(campoInteger.getValue()) == 0);
133 |
134 | campoLong.read("000001");
135 | assertNotNull(campoLong.getValue());
136 | assertTrue(campoLong.getValue() instanceof Long);
137 | assertTrue(new Long(1L).compareTo(campoLong.getValue()) == 0);
138 |
139 | campoDecimal.read("00000087598");
140 | assertNotNull(campoDecimal.getValue());
141 | assertTrue(campoDecimal.getValue() instanceof BigDecimal);
142 | assertTrue(new BigDecimal("875.98").compareTo(campoDecimal.getValue()) == 0);
143 |
144 | campoDecimal_v9.read("0000008759");
145 | assertNotNull(campoDecimal_v9.getValue());
146 | assertTrue(campoDecimal_v9.getValue() instanceof BigDecimal);
147 | assertTrue(new BigDecimal("875.9").compareTo(campoDecimal_v9
148 | .getValue()) == 0);
149 | }
150 |
151 | @Test(expected = IllegalArgumentException.class)
152 | public void testLerException() {
153 |
154 | campoString.read(null);
155 | campoDate.read(null);
156 | campoDate.read("");
157 | campoDate.read("abcd");
158 | campoDate.read("1a2MA1205");
159 | }
160 |
161 | @Test
162 | public void testEscrever() {
163 |
164 | assertNotNull(campoString.write());
165 | assertEquals(" ", campoString.write());
166 | assertEquals(8, campoString.write().length());
167 |
168 | assertNotNull(campoDate.write());
169 | assertEquals("220707", campoDate.write());
170 | assertEquals(6, campoDate.write().length());
171 |
172 | campoDate.setValue(Dates.invalidDate());
173 | campoDate.setFiller(Fillers.ZERO_LEFT);
174 | assertNotNull(campoDate.write());
175 | assertEquals("000000", campoDate.write());
176 | assertEquals(6, campoDate.write().length());
177 |
178 | assertNotNull(campoInteger.write());
179 | assertEquals("000000", campoInteger.write());
180 | assertEquals(6, campoInteger.write().length());
181 |
182 | assertNotNull(campoLong.write());
183 | assertEquals("000000", campoLong.write());
184 | assertEquals(6, campoLong.write().length());
185 |
186 | assertNotNull(campoDecimal.write());
187 | assertEquals("00000087598", campoDecimal.write());
188 | assertEquals(11, campoDecimal.write().length());
189 |
190 | assertNotNull(campoDecimal_v9.write());
191 | assertEquals("0000008759", campoDecimal_v9.write());
192 | assertEquals(10, campoDecimal_v9.write().length());
193 | }
194 |
195 | @Test(expected = IllegalStateException.class)
196 | public void testEscreverException() {
197 |
198 | FixedField campo = new FixedField("tamanho", 5);
199 | assertEquals(5, campo.write().length());
200 |
201 | FixedField campo1 = new FixedField(1234, 3);
202 | assertEquals(3, campo1.write().length());
203 |
204 | FixedField campo2 = new FixedField(12, 3);
205 | assertEquals(3, campo2.write().length());
206 | }
207 |
208 | @Test(expected = IllegalArgumentException.class)
209 | public void testSetCampo() {
210 | campoInteger.setValue(null);
211 | }
212 |
213 | @Test(expected = IllegalArgumentException.class)
214 | public void testSetTamanhoZero() {
215 | campoString.setFixedLength(0);
216 | }
217 |
218 | @Test(expected = IllegalArgumentException.class)
219 | public void testSetTamanhoNegativo() {
220 | campoString.setFixedLength(-1);
221 | }
222 |
223 | @Test(expected = IllegalArgumentException.class)
224 | public void testSetFiller() {
225 | campoString.setFiller(null);
226 | }
227 |
228 | }
229 |
--------------------------------------------------------------------------------
/src/test/java/org/jrimum/utilix/excludes/TestUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008 JRimum Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
7 | * applicable law or agreed to in writing, software distributed under the
8 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9 | * OF ANY KIND, either express or implied. See the License for the specific
10 | * language governing permissions and limitations under the License.
11 | *
12 | * Created at: 30/03/2008 - 18:15:56
13 | *
14 | * ================================================================================
15 | *
16 | * Direitos autorais 2008 JRimum Project
17 | *
18 | * Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
19 | * esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
20 | * cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
21 | * haja exigência legal ou acordo por escrito, a distribuição de software sob
22 | * esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
23 | * TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
24 | * reger permissões e limitações sob esta LICENÇA.
25 | *
26 | * Criado em: 30/03/2008 - 18:15:56
27 | *
28 | */
29 | package org.jrimum.utilix.excludes;
30 |
31 | import static org.junit.Assert.assertEquals;
32 | import static org.junit.Assert.assertNotNull;
33 | import static org.junit.Assert.assertTrue;
34 |
35 | import java.util.Date;
36 |
37 | import org.jrimum.texgit.type.FixedField;
38 | import org.jrimum.texgit.type.component.Field;
39 |
40 | /**
41 | *
42 | * Classe para uso em testes com Fields
.
43 | *
44 | *
45 | * @author Gilmar P.S.L.
46 | *
47 | * @since 0.2
48 | *
49 | * @version 0.2
50 | */
51 | public class TestUtil {
52 |
53 | public static void testEscritaCampo(FixedField campo, Class tipo,
54 | G valorDeEntrada, String strEsperada, int tamanho) {
55 |
56 | // >>>
57 | assertNotNull(campo);
58 | assertTrue(tipo.isInstance(campo.getValue()));
59 | assertEquals(valorDeEntrada, campo.getValue());
60 | assertNotNull(campo.write());
61 | assertEquals(strEsperada, campo.write());
62 | assertTrue(tamanho == campo.getFixedLength());
63 | assertTrue(tamanho == campo.write().length());
64 | }
65 |
66 | public static void testLeituraCampo(Field campo, Class tipo,
67 | G valorEsperado, String strDeEntrada) {
68 |
69 | // <<<
70 | campo.read(strDeEntrada);
71 | assertTrue(tipo.isInstance(campo.getValue()));
72 |
73 | if (campo.getValue() instanceof Date)// compareNoFormatoEscrito
74 | assertEquals(campo.getFormatter().format(valorEsperado), campo.write());
75 | else
76 | assertEquals(valorEsperado, campo.getValue());
77 |
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------