├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── pom.xml └── src ├── main ├── assembly │ ├── jrimum-texgit-examples.xml │ └── jrimum-texgit-with-dependencies.xml ├── java │ └── org │ │ └── jrimum │ │ └── texgit │ │ ├── FlatFile.java │ │ ├── ReadWriteStream.java │ │ ├── Record.java │ │ ├── Texgit.java │ │ ├── TexgitException.java │ │ ├── TextListStream.java │ │ ├── TextStream.java │ │ ├── engine │ │ ├── FixedFieldBuilder.java │ │ ├── FlatFileBuilder.java │ │ ├── RecordBuilder.java │ │ ├── RecordFactory.java │ │ ├── TexgitLanguageException.java │ │ ├── TexgitManager.java │ │ ├── TexgitSchemaValidator.java │ │ └── TexgitXmlReader.java │ │ ├── language │ │ ├── EnumFormats.java │ │ ├── EnumFormatsTypes.java │ │ ├── EnumPaddings.java │ │ ├── EnumSide.java │ │ ├── EnumTypes.java │ │ ├── MetaField.java │ │ ├── MetaFiller.java │ │ ├── MetaFlatFile.java │ │ ├── MetaFormatter.java │ │ ├── MetaGroupFields.java │ │ ├── MetaGroupRecords.java │ │ ├── MetaLayout.java │ │ ├── MetaOrderedField.java │ │ ├── MetaRecord.java │ │ ├── MetaTexgit.java │ │ ├── ObjectFactory.java │ │ └── package-info.java │ │ └── type │ │ ├── AbstractStringOfFields.java │ │ ├── Field.java │ │ ├── Filler.java │ │ ├── Fixed.java │ │ ├── FixedField.java │ │ ├── FixedLength.java │ │ ├── FixedSize.java │ │ └── component │ │ ├── BlockOfFields.java │ │ ├── Field.java │ │ ├── Filler.java │ │ ├── Fillers.java │ │ ├── FixedField.java │ │ ├── FlatFile.java │ │ ├── Record.java │ │ ├── RecordFactory.java │ │ └── Side.java └── resources │ └── TexgitSchema.xsd └── test └── java └── org └── jrimum ├── texgit └── type │ └── component │ ├── TestFiller.java │ └── TestFixedField.java └── utilix └── excludes └── TestUtil.java /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /target 3 | .classpath 4 | .DS_Store 5 | .project 6 | .settings 7 | 8 | 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Texgit Changelog 2 | ============================= 3 | 4 | 0.2.3 (2014/02/01) suport bopepo-0.2.3 5 | --------------------------------------- 6 | 7 | **Improvement** 8 | 9 | * #1: Implementação de testes para funcionalidade LineOfFields 10 | 11 | 12 | 0.2.0-SNAPSHOT (2010/12/07) incubation 13 | --------------------------------------- -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and 10 | distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 13 | owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all other entities 16 | that control, are controlled by, or are under common control with that entity. 17 | For the purposes of this definition, "control" means (i) the power, direct or 18 | indirect, to cause the direction or management of such entity, whether by 19 | contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the 20 | outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising 23 | permissions granted by this License. 24 | 25 | "Source" form shall mean the preferred form for making modifications, including 26 | but not limited to software source code, documentation source, and configuration 27 | files. 28 | 29 | "Object" form shall mean any form resulting from mechanical transformation or 30 | translation of a Source form, including but not limited to compiled object code, 31 | generated documentation, and conversions to other media types. 32 | 33 | "Work" shall mean the work of authorship, whether in Source or Object form, made 34 | available under the License, as indicated by a copyright notice that is included 35 | in or attached to the work (an example is provided in the Appendix below). 36 | 37 | "Derivative Works" shall mean any work, whether in Source or Object form, that 38 | is based on (or derived from) the Work and for which the editorial revisions, 39 | annotations, elaborations, or other modifications represent, as a whole, an 40 | original work of authorship. For the purposes of this License, Derivative Works 41 | shall not include works that remain separable from, or merely link (or bind by 42 | name) to the interfaces of, the Work and Derivative Works thereof. 43 | 44 | "Contribution" shall mean any work of authorship, including the original version 45 | of the Work and any modifications or additions to that Work or Derivative Works 46 | thereof, that is intentionally submitted to Licensor for inclusion in the Work 47 | by the copyright owner or by an individual or Legal Entity authorized to submit 48 | on behalf of the copyright owner. For the purposes of this definition, 49 | "submitted" means any form of electronic, verbal, or written communication sent 50 | to the Licensor or its representatives, including but not limited to 51 | communication on electronic mailing lists, source code control systems, and 52 | issue tracking systems that are managed by, or on behalf of, the Licensor for 53 | the purpose of discussing and improving the Work, but excluding communication 54 | that is conspicuously marked or otherwise designated in writing by the copyright 55 | owner as "Not a Contribution." 56 | 57 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 58 | of whom a Contribution has been received by Licensor and subsequently 59 | incorporated within the Work. 60 | 61 | 2. Grant of Copyright License. 62 | 63 | Subject to the terms and conditions of this License, each Contributor hereby 64 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 65 | irrevocable copyright license to reproduce, prepare Derivative Works of, 66 | publicly display, publicly perform, sublicense, and distribute the Work and such 67 | Derivative Works in Source or Object form. 68 | 69 | 3. Grant of Patent License. 70 | 71 | Subject to the terms and conditions of this License, each Contributor hereby 72 | grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, 73 | irrevocable (except as stated in this section) patent license to make, have 74 | made, use, offer to sell, sell, import, and otherwise transfer the Work, where 75 | such license applies only to those patent claims licensable by such Contributor 76 | that are necessarily infringed by their Contribution(s) alone or by combination 77 | of their Contribution(s) with the Work to which such Contribution(s) was 78 | submitted. If You institute patent litigation against any entity (including a 79 | cross-claim or counterclaim in a lawsuit) alleging that the Work or a 80 | Contribution incorporated within the Work constitutes direct or contributory 81 | patent infringement, then any patent licenses granted to You under this License 82 | for that Work shall terminate as of the date such litigation is filed. 83 | 84 | 4. Redistribution. 85 | 86 | You may reproduce and distribute copies of the Work or Derivative Works thereof 87 | in any medium, with or without modifications, and in Source or Object form, 88 | provided that You meet the following conditions: 89 | 90 | You must give any other recipients of the Work or Derivative Works a copy of 91 | this License; and 92 | You must cause any modified files to carry prominent notices stating that You 93 | changed the files; and 94 | You must retain, in the Source form of any Derivative Works that You distribute, 95 | all copyright, patent, trademark, and attribution notices from the Source form 96 | of the Work, excluding those notices that do not pertain to any part of the 97 | Derivative Works; and 98 | If the Work includes a "NOTICE" text file as part of its distribution, then any 99 | Derivative Works that You distribute must include a readable copy of the 100 | attribution notices contained within such NOTICE file, excluding those notices 101 | that do not pertain to any part of the Derivative Works, in at least one of the 102 | following places: within a NOTICE text file distributed as part of the 103 | Derivative Works; within the Source form or documentation, if provided along 104 | with the Derivative Works; or, within a display generated by the Derivative 105 | Works, if and wherever such third-party notices normally appear. The contents of 106 | the NOTICE file are for informational purposes only and do not modify the 107 | License. You may add Your own attribution notices within Derivative Works that 108 | You distribute, alongside or as an addendum to the NOTICE text from the Work, 109 | provided that such additional attribution notices cannot be construed as 110 | modifying the License. 111 | You may add Your own copyright statement to Your modifications and may provide 112 | additional or different license terms and conditions for use, reproduction, or 113 | distribution of Your modifications, or for any such Derivative Works as a whole, 114 | provided Your use, reproduction, and distribution of the Work otherwise complies 115 | with the conditions stated in this License. 116 | 117 | 5. Submission of Contributions. 118 | 119 | Unless You explicitly state otherwise, any Contribution intentionally submitted 120 | for inclusion in the Work by You to the Licensor shall be under the terms and 121 | conditions of this License, without any additional terms or conditions. 122 | Notwithstanding the above, nothing herein shall supersede or modify the terms of 123 | any separate license agreement you may have executed with Licensor regarding 124 | such Contributions. 125 | 126 | 6. Trademarks. 127 | 128 | This License does not grant permission to use the trade names, trademarks, 129 | service marks, or product names of the Licensor, except as required for 130 | reasonable and customary use in describing the origin of the Work and 131 | reproducing the content of the NOTICE file. 132 | 133 | 7. Disclaimer of Warranty. 134 | 135 | Unless required by applicable law or agreed to in writing, Licensor provides the 136 | Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, 137 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 138 | including, without limitation, any warranties or conditions of TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are 140 | solely responsible for determining the appropriateness of using or 141 | redistributing the Work and assume any risks associated with Your exercise of 142 | permissions under this License. 143 | 144 | 8. Limitation of Liability. 145 | 146 | In no event and under no legal theory, whether in tort (including negligence), 147 | contract, or otherwise, unless required by applicable law (such as deliberate 148 | and grossly negligent acts) or agreed to in writing, shall any Contributor be 149 | liable to You for damages, including any direct, indirect, special, incidental, 150 | or consequential damages of any character arising as a result of this License or 151 | out of the use or inability to use the Work (including but not limited to 152 | damages for loss of goodwill, work stoppage, computer failure or malfunction, or 153 | any and all other commercial damages or losses), even if such Contributor has 154 | been advised of the possibility of such damages. 155 | 156 | 9. Accepting Warranty or Additional Liability. 157 | 158 | While redistributing the Work or Derivative Works thereof, You may choose to 159 | offer, and charge a fee for, acceptance of support, warranty, indemnity, or 160 | other liability obligations and/or rights consistent with this License. However, 161 | in accepting such obligations, You may act only on Your own behalf and on Your 162 | sole responsibility, not on behalf of any other Contributor, and only if You 163 | agree to indemnify, defend, and hold each Contributor harmless for any liability 164 | incurred by, or claims asserted against, such Contributor by reason of your 165 | accepting any such warranty or additional liability. 166 | 167 | END OF TERMS AND CONDITIONS 168 | 169 | APPENDIX: How to apply the Apache License to your work 170 | 171 | To apply the Apache License to your work, attach the following boilerplate 172 | notice, with the fields enclosed by brackets "[]" replaced with your own 173 | identifying information. (Don't include the brackets!) The text should be 174 | enclosed in the appropriate comment syntax for the file format. We also 175 | recommend that a file or class name and description of purpose be included on 176 | the same "printed page" as the copyright notice for easier identification within 177 | third-party archives. 178 | 179 | Copyright [yyyy] [name of copyright owner] 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Texgit 2 | ====== 3 | 4 | [![Build Status](https://ci-jrimum.rhcloud.com/buildStatus/icon?job=Texgit)](https://ci-jrimum.rhcloud.com) 5 | 6 | O projeto Texgit é um componente e framework em Java que facilita a manipulação de arquivos Flat Files (arquivo-texto) através de objetos. 7 | 8 | Diversas empresas já usam o Texgit em produção e estão colaborando no Design do componente e da API. 9 | 10 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | org.jrimum 6 | jrimum-texgit 7 | Projeto Texgit 8 | 0.2.3-DEV-SNAPSHOT 9 | Projeto open source de componentes de software para o domínio de negócios do Brasil. 10 | http://www.jrimum.org/texgit 11 | 12 | 13 | 14 | The Apache Software License, Version 2.0 15 | http://www.apache.org/licenses/LICENSE-2.0.txt 16 | repo 17 | 18 | 19 | 20 | 21 | Projeto JRimum 22 | http://www.jrimum.org 23 | 24 | 25 | 26 | GitHub 27 | http://github.com/jrimum/texgit/issues 28 | 29 | 30 | 31 | http://github.com/jrimum/texgit 32 | 33 | 34 | 35 | 36 | Gilmar P. S. L. 37 | gilmatryx@gmail.com 38 | 39 | 40 | Misael Barreto 41 | misaelbarreto@gmail.com 42 | 43 | 44 | Rômulo Augusto 45 | romulomail@gmail.com 46 | 47 | 48 | 49 | 50 | UTF-8 51 | UTF-8 52 | 53 | 54 | 55 | 56 | 57 | org.apache.maven.plugins 58 | maven-compiler-plugin 59 | 3.1 60 | 61 | 1.5 62 | 1.5 63 | 64 | 65 | 66 | org.codehaus.mojo 67 | animal-sniffer-maven-plugin 68 | 1.6 69 | 70 | 71 | org.codehaus.mojo.signature 72 | java15 73 | 1.0 74 | 75 | 76 | 77 | 78 | animal-sniffer 79 | compile 80 | 81 | check 82 | 83 | 84 | 85 | 86 | 87 | maven-assembly-plugin 88 | 2.4 89 | 90 | 91 | src/main/assembly/jrimum-texgit-with-dependencies.xml 92 | 93 | 94 | 95 | 96 | make-assembly 97 | package 98 | 99 | single 100 | 101 | 102 | 103 | 104 | 105 | org.apache.maven.plugins 106 | maven-surefire-plugin 107 | 2.16 108 | 109 | false 110 | 111 | org/jrimum/texgit/**/* 112 | 113 | 114 | org/jrimum/texgit/excludes/**/* 115 | org/jrimum/texgit/**/*$* 116 | 117 | 118 | 119 | 120 | org.apache.maven.plugins 121 | maven-source-plugin 122 | 2.2.1 123 | 124 | 125 | attach-sources 126 | package 127 | 128 | jar 129 | 130 | 131 | 132 | 133 | 134 | org.apache.maven.plugins 135 | maven-javadoc-plugin 136 | 2.9.1 137 | 138 | 139 | attach-javadoc 140 | package 141 | 142 | jar 143 | 144 | 145 | 146 | 147 | UTF-8 148 | UTF-8 149 | true 150 | private 151 | 152 | 153 | 154 | org.apache.maven.plugins 155 | maven-deploy-plugin 156 | 2.8.1 157 | 158 | 159 | 160 | 161 | 162 | 163 | org.jrimum 164 | jrimum-utilix 165 | 0.2.3-DEV-SNAPSHOT 166 | 167 | 168 | sun-jaxb 169 | jaxb-api 170 | 2.2 171 | 172 | 173 | sun-jaxb 174 | jaxb-impl 175 | 2.2 176 | 177 | 178 | 179 | junit 180 | junit 181 | 4.11 182 | test 183 | 184 | 185 | 186 | 187 | 188 | JBoss Repository 189 | http://repository.jboss.org/nexus/content/groups/public-jboss/ 190 | 191 | 192 | jrimum.org 193 | http://jrimum.org/maven/content/groups/public/ 194 | 195 | true 196 | 197 | 198 | 199 | 200 | 201 | 202 | org.jrimum.snapshots 203 | http://jrimum.org/maven/content/repositories/org.jrimum.snapshots/ 204 | 205 | 206 | org.jrimum.releases 207 | http://jrimum.org/maven/content/repositories/org.jrimum.releases/ 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /src/main/assembly/jrimum-texgit-examples.xml: -------------------------------------------------------------------------------- 1 | 5 | examples 6 | 7 | zip 8 | 9 | 10 | 11 | src/examples/java 12 | true 13 | / 14 | 15 | **/*.java 16 | 17 | 18 | 19 | src/examples/resources 20 | true 21 | /resources 22 | 23 | **/** 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/assembly/jrimum-texgit-with-dependencies.xml: -------------------------------------------------------------------------------- 1 | 5 | dep 6 | 7 | jar 8 | 9 | false 10 | 11 | 12 | / 13 | true 14 | true 15 | runtime 16 | 17 | commons-lang:commons-lang 18 | log4j:log4j 19 | sun-jaxb:jaxb-api 20 | sun-jaxb:jaxb-impl 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/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; 30 | 31 | import java.util.Collection; 32 | 33 | /** 34 | * @author Gilmar P.S.L. 35 | * 36 | * @param 37 | */ 38 | public interface FlatFile extends TextListStream { 39 | 40 | // Registros individuais 41 | 42 | public G createRecord(String idType); 43 | 44 | public FlatFile addRecord(G record); 45 | 46 | public G getRecord(String idName); 47 | 48 | public G removeRecord(String idName); 49 | 50 | // Grupos de Registros (Registros que se repetem) 51 | 52 | public FlatFile addRecords(String idName, Collection records); 53 | 54 | public FlatFile setRecords(String idName, Collection records); 55 | 56 | public Collection getRecords(String idName); 57 | 58 | // Todos os Registros 59 | 60 | public FlatFile addAllRecords(Collection records); 61 | 62 | public FlatFile setAllRecords(Collection records); 63 | 64 | public Collection getAllRecords(); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/ReadWriteStream.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:10 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:10 27 | * 28 | */ 29 | 30 | package org.jrimum.texgit; 31 | 32 | import java.io.Serializable; 33 | 34 | /** 35 | *

36 | * Interface genérica e representativa de coisas que necessitam de operações de 37 | * fluxo de escrita e leitura. 38 | *

39 | * 40 | * @author Gilmar P.S.L. 41 | * 42 | * @since 0.2 43 | * 44 | * @version 0.2 45 | */ 46 | public interface ReadWriteStream extends Serializable { 47 | 48 | /** 49 | *

50 | * Escreve o tipo infomado. 51 | *

52 | * 53 | * @return Um valor no mesmo tipo do tipo parametrizado 54 | * @since 0.2 55 | */ 56 | G write(); 57 | 58 | /** 59 | *

60 | * Lê o tipo informado. 61 | *

62 | * 63 | * @param g - Valor a ser lido 64 | * 65 | * @since 0.2 66 | */ 67 | void read(G g); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/Record.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; 30 | 31 | import java.util.List; 32 | 33 | /** 34 | * @author Gilmar P.S.L. 35 | * 36 | */ 37 | public interface Record extends TextStream { 38 | 39 | public Record setValue(String fieldName, G value); 40 | 41 | public G getValue(String fieldName); 42 | 43 | public Record addInnerRecord(Record record); 44 | 45 | public List getInnerRecords(); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/Texgit.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; 30 | 31 | import static org.apache.commons.lang.StringUtils.isNotBlank; 32 | import static org.jrimum.utilix.Objects.isNotNull; 33 | 34 | import java.io.ByteArrayInputStream; 35 | import java.io.File; 36 | import java.io.FileInputStream; 37 | import java.io.InputStream; 38 | import java.net.URL; 39 | 40 | import org.jrimum.texgit.engine.TexgitManager; 41 | 42 | /** 43 | * @author Gilmar P.S.L. 44 | * 45 | */ 46 | public final class Texgit { 47 | 48 | public static final FlatFile createFlatFile(String xmlDefFilePath) 49 | throws TexgitException { 50 | 51 | try { 52 | 53 | if (isNotBlank(xmlDefFilePath)) 54 | return createFlatFile(new File(xmlDefFilePath)); 55 | 56 | } catch (Exception e) { 57 | throw new TexgitException(e); 58 | } 59 | 60 | return null; 61 | } 62 | 63 | public static final FlatFile createFlatFile(File xmlDefFile) 64 | throws TexgitException { 65 | 66 | try { 67 | 68 | if (isNotNull(xmlDefFile)) { 69 | 70 | return createFlatFile(new FileInputStream(xmlDefFile)); 71 | } 72 | 73 | } catch (Exception e) { 74 | throw new TexgitException(e); 75 | } 76 | 77 | return null; 78 | } 79 | 80 | public static final FlatFile createFlatFile(URL xmlDefUrl) 81 | throws TexgitException { 82 | 83 | try { 84 | 85 | if (isNotNull(xmlDefUrl)) { 86 | 87 | return TexgitManager.buildFlatFile(xmlDefUrl.openStream()); 88 | } 89 | 90 | } catch (Exception e) { 91 | throw new TexgitException(e); 92 | } 93 | 94 | 95 | return null; 96 | } 97 | 98 | public static final FlatFile createFlatFile(byte[] xmlDefBytes) 99 | throws TexgitException { 100 | 101 | try { 102 | 103 | if (isNotNull(xmlDefBytes)) { 104 | 105 | return TexgitManager.buildFlatFile(new ByteArrayInputStream(xmlDefBytes)); 106 | } 107 | 108 | } catch (Exception e) { 109 | throw new TexgitException(e); 110 | } 111 | 112 | return null; 113 | } 114 | 115 | public static final FlatFile createFlatFile(InputStream xmlDefStream) 116 | throws TexgitException { 117 | 118 | if (isNotNull(xmlDefStream)) { 119 | 120 | return TexgitManager.buildFlatFile(xmlDefStream); 121 | } 122 | 123 | return null; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/TexgitException.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; 30 | 31 | /** 32 | * 33 | *

34 | * Invólucro para exceções ocorridas no componente. 35 | *

36 | * 37 | * @author Gilmar P.S.L. 38 | * 39 | * */ 40 | @SuppressWarnings("serial") 41 | public class TexgitException extends RuntimeException { 42 | 43 | /** 44 | * 45 | */ 46 | public TexgitException() { 47 | super(); 48 | 49 | } 50 | 51 | /** 52 | * @param arg0 53 | * @param arg1 54 | */ 55 | public TexgitException(String arg0, Throwable arg1) { 56 | super(arg0, arg1); 57 | 58 | } 59 | 60 | /** 61 | * @param arg0 62 | */ 63 | public TexgitException(String arg0) { 64 | super(arg0); 65 | 66 | } 67 | 68 | /** 69 | * @param arg0 70 | */ 71 | public TexgitException(Throwable arg0) { 72 | super(arg0); 73 | 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/TextListStream.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; 30 | 31 | import java.util.List; 32 | 33 | /** 34 | * @author Gilmar P.S.L. 35 | * 36 | */ 37 | public interface TextListStream extends ReadWriteStream> { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/TextStream.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:20 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:20 27 | * 28 | */ 29 | 30 | package org.jrimum.texgit; 31 | 32 | 33 | /** 34 | *

Interface usada para objetos com serviços de leitura e escrita de textos.

35 | * 36 | * @author Gilmar P.S.L 37 | * @author Misael Barreto 38 | * @author Rômulo Augusto 39 | * @author Nordeste Fomento 40 | * Mercantil 41 | * 42 | * @since 0.2 43 | * 44 | * @version 0.2 45 | */ 46 | public interface TextStream extends ReadWriteStream { 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/FixedFieldBuilder.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.engine; 30 | 31 | import static org.apache.commons.lang.StringUtils.EMPTY; 32 | import static org.apache.commons.lang.StringUtils.countMatches; 33 | import static org.apache.commons.lang.StringUtils.isNotBlank; 34 | import static org.jrimum.utilix.Objects.isNotNull; 35 | 36 | import java.math.BigDecimal; 37 | import java.text.DateFormat; 38 | import java.text.DecimalFormat; 39 | import java.text.Format; 40 | import java.text.ParseException; 41 | import java.text.SimpleDateFormat; 42 | import java.util.Date; 43 | 44 | import org.jrimum.texgit.TexgitException; 45 | import org.jrimum.texgit.language.EnumFormats; 46 | import org.jrimum.texgit.language.EnumFormatsTypes; 47 | import org.jrimum.texgit.language.MetaField; 48 | import org.jrimum.texgit.type.Filler; 49 | import org.jrimum.texgit.type.component.Fillers; 50 | import org.jrimum.texgit.type.component.FixedField; 51 | import org.jrimum.texgit.type.component.Side; 52 | import org.jrimum.utilix.Dates; 53 | 54 | /** 55 | * @author Gilmar P.S.L. 56 | * 57 | */ 58 | class FixedFieldBuilder { 59 | 60 | private final static String BASE_DECIMAL_FORMAT = "0."; 61 | 62 | static FixedField build(MetaField metaField) { 63 | 64 | FixedField fixedField = null; 65 | 66 | try { 67 | 68 | fixedField = getInstance(metaField); 69 | 70 | } catch (ParseException e) { 71 | throw new TexgitException("Field: " + metaField.getName(), e); 72 | } 73 | 74 | return fixedField; 75 | } 76 | 77 | private static FixedField getInstance(MetaField metaField) 78 | throws ParseException { 79 | 80 | FixedField fField = null; 81 | 82 | Format formatter = getFormater(metaField); 83 | 84 | switch (metaField.getType()) { 85 | 86 | case CHARACTER: 87 | FixedField fCHR = new FixedField(); 88 | if (isNotBlank(metaField.getValue())) 89 | if(metaField.getValue().length() == 1) 90 | fCHR.setValue(metaField.getValue().charAt(0)); 91 | else 92 | throw new IllegalArgumentException("Tipo character deve ter apenas 1!"); 93 | else 94 | fCHR.setValue(' '); 95 | fField = fCHR; 96 | break; 97 | case STRING: 98 | FixedField fSTR = new FixedField(); 99 | if (isNotBlank(metaField.getValue())) 100 | fSTR.setValue(metaField.getValue()); 101 | else 102 | fSTR.setValue(EMPTY); 103 | fField = fSTR; 104 | break; 105 | case INTEGER: 106 | FixedField fINT = new FixedField(); 107 | if (isNotBlank(metaField.getValue())) 108 | fINT.setValue(Integer.parseInt(metaField.getValue())); 109 | else 110 | fINT.setValue(Integer.valueOf(0)); 111 | fField = fINT; 112 | break; 113 | case LONG: 114 | FixedField fLNG = new FixedField(); 115 | if (isNotBlank(metaField.getValue())) 116 | fLNG.setValue(Long.parseLong(metaField.getValue())); 117 | else 118 | fLNG.setValue(Long.valueOf(0)); 119 | fField = fLNG; 120 | break; 121 | case FLOAT: 122 | FixedField fFLT = new FixedField(); 123 | if (isNotBlank(metaField.getValue())) 124 | fFLT.setValue(Float.parseFloat(metaField.getValue())); 125 | else 126 | fFLT.setValue(Float.valueOf(0)); 127 | fField = fFLT; 128 | break; 129 | case DOUBLE: 130 | FixedField fDBE = new FixedField(); 131 | if (isNotBlank(metaField.getValue())) 132 | fDBE.setValue(Double.parseDouble(metaField.getValue())); 133 | else 134 | fDBE.setValue(Double.valueOf(0)); 135 | fField = fDBE; 136 | break; 137 | case BIGDECIMAL: 138 | FixedField fBDL = new FixedField(); 139 | if (isNotBlank(metaField.getValue())) 140 | fBDL.setValue(new BigDecimal(DecimalFormat.class 141 | .cast(formatter).parse(metaField.getValue()) 142 | .doubleValue())); 143 | else 144 | fBDL.setValue(BigDecimal.ZERO); 145 | fField = fBDL; 146 | break; 147 | case DATE: 148 | FixedField fDTE = new FixedField(); 149 | if (isNotBlank(metaField.getValue())){ 150 | 151 | fDTE.setValue(DateFormat.class.cast(formatter).parse( 152 | metaField.getValue())); 153 | } 154 | else{ 155 | 156 | fDTE.setValue(Dates.invalidDate()); 157 | } 158 | fField = fDTE; 159 | break; 160 | } 161 | 162 | fField.setName(metaField.getName()); 163 | fField.setFixedLength(metaField.getLength()); 164 | fField.setFiller(getFiller(metaField)); 165 | fField.setBlankAccepted(metaField.isBlankAccepted()); 166 | fField.setTruncate(metaField.isTruncate()); 167 | 168 | if(isNotNull(formatter)) 169 | fField.setFormatter(formatter); 170 | 171 | return fField; 172 | } 173 | 174 | private static Filler getFiller(MetaField metaField) { 175 | 176 | Filler filler = null; 177 | 178 | if (isNotNull(metaField.getFiller())) { 179 | 180 | org.jrimum.texgit.type.component.Filler filr = new org.jrimum.texgit.type.component.Filler(); 181 | filr.setPadding(metaField.getFiller().getPadding()); 182 | filr.setSideToFill(Side.valueOf(metaField.getFiller() 183 | .getSideToFill().name())); 184 | filler = filr; 185 | 186 | } else { 187 | filler = Fillers.valueOf(metaField.getPadding().name()); 188 | } 189 | 190 | return filler; 191 | } 192 | 193 | private static Format getFormater(MetaField metaField) { 194 | 195 | Format formatter = null; 196 | 197 | if (isNotNull(metaField.getFormatter())) { 198 | 199 | formatter = buildFormat(metaField.getFormatter().getFormat(), 200 | metaField.getFormatter().getType()); 201 | 202 | } else { 203 | if(isNotNull(metaField.getFormat())){ 204 | 205 | EnumFormats format = metaField.getFormat(); 206 | 207 | EnumFormatsTypes type = EnumFormatsTypes.valueOf(format.name() 208 | .split("_")[0]); 209 | 210 | formatter = buildFormat(buildFormat(format, type), type); 211 | } 212 | } 213 | 214 | return formatter; 215 | } 216 | 217 | private static Format buildFormat(String strFormat, EnumFormatsTypes type) { 218 | 219 | Format format = null; 220 | 221 | switch (type) { 222 | 223 | case DATE: 224 | format = new SimpleDateFormat(strFormat); 225 | break; 226 | case DECIMAL: 227 | format = new DecimalFormat(strFormat); 228 | break; 229 | } 230 | 231 | return format; 232 | } 233 | 234 | private static String buildFormat(EnumFormats format, EnumFormatsTypes type) { 235 | 236 | String strFormat = EMPTY; 237 | /* 238 | * DATE_DDMMYY, DATE_DDMMYYYY, DATE_YYMMDD, DATE_YYYYMMDD, 239 | * DECIMAL_D,DECIMAL_DD, DECIMAL_DDD, DECIMAL_DDDD; 240 | */ 241 | String defFormat = format.name().split("_")[1]; 242 | 243 | switch (type) { 244 | case DATE: 245 | 246 | defFormat = defFormat.replaceAll("D", "d"); 247 | strFormat = defFormat.replaceAll("Y", "y"); 248 | 249 | break; 250 | case DECIMAL: 251 | 252 | int lengthToFill = BASE_DECIMAL_FORMAT.length() 253 | + countMatches(defFormat, "D"); 254 | 255 | strFormat = Fillers.ZERO_RIGHT.fill( 256 | BASE_DECIMAL_FORMAT, lengthToFill); 257 | 258 | break; 259 | } 260 | 261 | return strFormat; 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/FlatFileBuilder.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.engine; 30 | 31 | import static org.jrimum.utilix.Objects.isNotNull; 32 | 33 | import java.util.ArrayList; 34 | import java.util.HashSet; 35 | import java.util.List; 36 | import java.util.Set; 37 | 38 | import org.jrimum.texgit.language.MetaFlatFile; 39 | import org.jrimum.texgit.language.MetaRecord; 40 | import org.jrimum.texgit.type.component.FlatFile; 41 | 42 | 43 | 44 | /** 45 | * @author Gilmar P.S.L. 46 | * 47 | */ 48 | public class FlatFileBuilder { 49 | 50 | static FlatFile build(MetaFlatFile mFlatFile) { 51 | 52 | FlatFile ff = null; 53 | 54 | List metaRecords = mFlatFile.getGroupOfRecords().getRecords(); 55 | 56 | ff = new FlatFile(new RecordFactory(metaRecords)); 57 | 58 | Set repitables = new HashSet(); 59 | 60 | List recordsOrder = new ArrayList(); 61 | 62 | if (isNotNull(metaRecords)) { 63 | 64 | if (!metaRecords.isEmpty()) { 65 | 66 | for (MetaRecord mRec : metaRecords) { 67 | 68 | recordsOrder.add(mRec.getName()); 69 | 70 | if (mRec.isRepeatable()) 71 | repitables.add(mRec.getName()); 72 | } 73 | } 74 | } 75 | 76 | ff.setRecordsOrder(recordsOrder); 77 | ff.setRepitablesRecords(repitables); 78 | 79 | return ff; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/RecordBuilder.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.engine; 30 | 31 | import static org.jrimum.utilix.Objects.isNotNull; 32 | import static org.jrimum.utilix.Objects.isNull; 33 | 34 | import java.util.ArrayList; 35 | import java.util.HashSet; 36 | import java.util.List; 37 | 38 | import org.jrimum.texgit.language.MetaField; 39 | import org.jrimum.texgit.language.MetaOrderedField; 40 | import org.jrimum.texgit.language.MetaRecord; 41 | import org.jrimum.texgit.type.component.FixedField; 42 | import org.jrimum.texgit.type.component.Record; 43 | 44 | 45 | 46 | /** 47 | * @author Gilmar P.S.L. 48 | * 49 | */ 50 | class RecordBuilder { 51 | 52 | @SuppressWarnings("unchecked") 53 | static Record build(MetaRecord metaRecord) { 54 | 55 | int strLength = getStringLength(metaRecord.getGroupOfFields().getFields()); 56 | int fldSize = metaRecord.getGroupOfFields().getFields().size(); 57 | 58 | MetaOrderedField id = metaRecord.getGroupOfFields().getIdType(); 59 | MetaOrderedField sequencialNumber = metaRecord.getGroupOfFields().getSequencialNumber(); 60 | 61 | if(isNotNull(id)){ 62 | fldSize += 1; 63 | strLength += id.getLength(); 64 | } 65 | 66 | if(isNotNull(sequencialNumber)){ 67 | fldSize += 1; 68 | strLength += sequencialNumber.getLength(); 69 | } 70 | 71 | Record record = new Record(strLength,fldSize); 72 | 73 | record.setName(metaRecord.getName()); 74 | record.setDescription(metaRecord.getDescription()); 75 | 76 | /* 77 | * getPossition eh de 1 a X 78 | * e nao de 0 a X. 79 | */ 80 | if(isNotNull(id)){ 81 | record.setIdType((FixedField) FixedFieldBuilder.build(id)); 82 | record.set(id.getPosition()-1, record.getIdType()); 83 | } 84 | 85 | if(isNotNull(sequencialNumber)){ 86 | record.setSequencialNumber((FixedField) FixedFieldBuilder.build(sequencialNumber)); 87 | record.set(sequencialNumber.getPosition()-1,record.getSequencialNumber()); 88 | } 89 | 90 | List fields = metaRecord.getGroupOfFields().getFields(); 91 | 92 | /* 93 | * As somas sao para caso id ou sequencia jah 94 | * estejam na devida posicao. 95 | */ 96 | for(MetaField mField : fields){ 97 | 98 | if(isNull(record.get(fields.indexOf(mField)))) 99 | record.set(fields.indexOf(mField), FixedFieldBuilder.build(mField)); 100 | else 101 | if(isNull(record.get(fields.indexOf(mField)+1))) 102 | record.set(fields.indexOf(mField) + 1, FixedFieldBuilder.build(mField)); 103 | else 104 | record.set(fields.indexOf(mField) + 2, FixedFieldBuilder.build(mField)); 105 | } 106 | 107 | // innerRecords 108 | if (isNotNull(metaRecord.getGroupOfInnerRecords())){ 109 | 110 | record.setHeadOfGroup(true); 111 | record.setDeclaredInnerRecords(new ArrayList(metaRecord.getGroupOfInnerRecords().getRecords().size())); 112 | record.setRepitablesRecords(new HashSet()); 113 | 114 | List metaInnerRecords = metaRecord.getGroupOfInnerRecords().getRecords(); 115 | 116 | for(MetaRecord mRecord : metaInnerRecords){ 117 | record.getDeclaredInnerRecords().add(mRecord.getName()); 118 | if(mRecord.isRepeatable()) 119 | record.getRepitablesRecords().add(mRecord.getName()); 120 | } 121 | 122 | }else 123 | record.setHeadOfGroup(false); 124 | 125 | return record; 126 | } 127 | 128 | private static int getStringLength(List fields){ 129 | int length = 0; 130 | 131 | for(MetaField mField : fields) 132 | length += mField.getLength(); 133 | 134 | return length; 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/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.engine; 30 | 31 | import static org.apache.commons.lang.StringUtils.isNotBlank; 32 | import static org.jrimum.utilix.Objects.isNotNull; 33 | 34 | import java.util.HashMap; 35 | import java.util.List; 36 | import java.util.Map; 37 | 38 | import org.jrimum.texgit.language.MetaRecord; 39 | import org.jrimum.texgit.type.component.Record; 40 | 41 | 42 | 43 | /** 44 | * @author Gilmar P.S.L. 45 | * 46 | */ 47 | public class RecordFactory implements org.jrimum.texgit.type.component.RecordFactory { 48 | 49 | private Map name_record; 50 | 51 | RecordFactory(List metaRecords) { 52 | 53 | if (isNotNull(metaRecords)) { 54 | if (!metaRecords.isEmpty()) { 55 | 56 | name_record = new HashMap(metaRecords 57 | .size()); 58 | 59 | for (MetaRecord mRecord : metaRecords) { 60 | 61 | name_record.put(mRecord.getName(), mRecord); 62 | 63 | if (isNotNull(mRecord.getGroupOfInnerRecords())) 64 | loadInnerRecords(name_record, mRecord 65 | .getGroupOfInnerRecords().getRecords()); 66 | } 67 | } 68 | } 69 | } 70 | 71 | private void loadInnerRecords(Map name_record, 72 | List innerMetaRecords) { 73 | 74 | if (isNotNull(innerMetaRecords)) { 75 | if (!innerMetaRecords.isEmpty()) { 76 | 77 | for (MetaRecord iMetaRecord : innerMetaRecords) { 78 | 79 | name_record.put(iMetaRecord.getName(), iMetaRecord); 80 | 81 | if (isNotNull(iMetaRecord.getGroupOfInnerRecords())) 82 | loadInnerRecords(name_record, iMetaRecord 83 | .getGroupOfInnerRecords().getRecords()); 84 | } 85 | } 86 | } 87 | 88 | } 89 | 90 | public Record create(String name) { 91 | 92 | Record record = null; 93 | 94 | if (isNotBlank(name)) 95 | if (name_record.containsKey(name)) 96 | record = RecordBuilder.build(name_record.get(name)); 97 | 98 | return record; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/TexgitLanguageException.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.engine; 30 | 31 | import org.jrimum.texgit.TexgitException; 32 | 33 | /** 34 | * @author Gilmar P.S.L. 35 | * 36 | */ 37 | @SuppressWarnings("serial") 38 | public class TexgitLanguageException extends TexgitException { 39 | 40 | /** 41 | * 42 | */ 43 | public TexgitLanguageException() { 44 | super(); 45 | 46 | } 47 | 48 | /** 49 | * @param arg0 50 | * @param arg1 51 | */ 52 | public TexgitLanguageException(String arg0, Throwable arg1) { 53 | super(arg0, arg1); 54 | 55 | } 56 | 57 | /** 58 | * @param arg0 59 | */ 60 | public TexgitLanguageException(String arg0) { 61 | super(arg0); 62 | 63 | } 64 | 65 | /** 66 | * @param arg0 67 | */ 68 | public TexgitLanguageException(Throwable arg0) { 69 | super(arg0); 70 | 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/TexgitManager.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.engine; 30 | 31 | import java.io.InputStream; 32 | 33 | import org.jrimum.texgit.FlatFile; 34 | import org.jrimum.texgit.Record; 35 | import org.jrimum.texgit.TexgitException; 36 | import org.jrimum.texgit.language.MetaTexgit; 37 | 38 | /** 39 | * @author Gilmar P.S.L. 40 | * 41 | */ 42 | public class TexgitManager { 43 | 44 | public static FlatFile buildFlatFile(InputStream xmlDefStream) { 45 | 46 | FlatFile iFlatFile = null; 47 | 48 | try { 49 | 50 | MetaTexgit tgMeta = TexgitXmlReader.parse(xmlDefStream); 51 | 52 | iFlatFile = FlatFileBuilder.build(tgMeta.getFlatFile()); 53 | 54 | } catch (Exception e) { 55 | throw new TexgitException(e); 56 | } 57 | 58 | return iFlatFile; 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/TexgitSchemaValidator.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.engine; 30 | 31 | import javax.xml.bind.ValidationEvent; 32 | import javax.xml.bind.ValidationEventHandler; 33 | import javax.xml.bind.ValidationEventLocator; 34 | 35 | /** 36 | * @author Gilmar P.S.L. 37 | * 38 | */ 39 | class TexgitSchemaValidator implements ValidationEventHandler { 40 | 41 | public boolean handleEvent(ValidationEvent event) { 42 | 43 | boolean handled = false; 44 | 45 | if (event.getSeverity() == ValidationEvent.WARNING) { 46 | 47 | System.err.println(getMensagem("ATENÇÃO LAYOUT INCONSISTENTE!\n", 48 | event)); 49 | 50 | handled = true; 51 | 52 | } else 53 | // ERROR 54 | System.err.println(getMensagem("ERRO NO LAYOUT!\n", event)); 55 | 56 | return handled; 57 | } 58 | 59 | private String getMensagem(String msg, ValidationEvent event) { 60 | 61 | ValidationEventLocator local = event.getLocator(); 62 | 63 | return msg + 64 | 65 | "Linha { " + local.getLineNumber() + " } " + "Conluna [ " 66 | + local.getColumnNumber() + " ] " + event.getMessage(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/engine/TexgitXmlReader.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.engine; 30 | 31 | import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; 32 | import static org.jrimum.utilix.Objects.isNotNull; 33 | 34 | import java.io.InputStream; 35 | 36 | import javax.xml.bind.JAXBContext; 37 | import javax.xml.bind.JAXBException; 38 | import javax.xml.bind.Unmarshaller; 39 | import javax.xml.validation.Schema; 40 | import javax.xml.validation.SchemaFactory; 41 | 42 | import org.jrimum.texgit.Texgit; 43 | import org.jrimum.texgit.TexgitException; 44 | import org.jrimum.texgit.language.MetaTexgit; 45 | import org.jrimum.utilix.ClassLoaders; 46 | import org.xml.sax.SAXException; 47 | 48 | 49 | 50 | /** 51 | * @author Gilmar P.S.L. 52 | * 53 | */ 54 | class TexgitXmlReader { 55 | 56 | public static MetaTexgit parse(InputStream xmlDefStream) throws TexgitException { 57 | 58 | MetaTexgit txg = null; 59 | 60 | if (isNotNull(xmlDefStream)) { 61 | 62 | try { 63 | 64 | JAXBContext aJaxbContext = JAXBContext 65 | .newInstance(MetaTexgit.class); 66 | 67 | Unmarshaller aUnmarshaller = aJaxbContext.createUnmarshaller(); 68 | 69 | SchemaFactory aSchemaFactory = SchemaFactory 70 | .newInstance(W3C_XML_SCHEMA_NS_URI); 71 | 72 | Schema schema = aSchemaFactory.newSchema(ClassLoaders.getResource("TexgitSchema.xsd",Texgit.class)); 73 | 74 | aUnmarshaller.setSchema(schema); 75 | 76 | aUnmarshaller.setEventHandler(new TexgitSchemaValidator()); 77 | 78 | txg = (MetaTexgit) aUnmarshaller.unmarshal(xmlDefStream); 79 | 80 | } catch (SAXException e) { 81 | 82 | throw new TexgitLanguageException(e); 83 | 84 | } catch (JAXBException e) { 85 | 86 | throw new TexgitLanguageException(e); 87 | 88 | } 89 | } 90 | 91 | return txg; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/language/EnumFormats.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.XmlEnum; 39 | 40 | /** 41 | * 42 | * 43 | *

44 | * Formatos pr� definidos suportados pelo componente. 45 | *

46 | * 47 | * 48 | * 49 | *

50 | * Java class for enumFormats. 51 | * 52 | *

53 | * The following schema fragment specifies the expected content contained within 54 | * this class. 55 | *

56 | * 57 | *

58 |  * <simpleType name="enumFormats">
59 |  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
60 |  *     <enumeration value="DATE_DDMMYY"/>
61 |  *     <enumeration value="DATE_DDMMYYYY"/>
62 |  *     <enumeration value="DATE_YYMMDD"/>
63 |  *     <enumeration value="DATE_YYYYMMDD"/>
64 |  *     <enumeration value="DECIMAL_D"/>
65 |  *     <enumeration value="DECIMAL_DD"/>
66 |  *     <enumeration value="DECIMAL_DDD"/>
67 |  *     <enumeration value="DECIMAL_DDDD"/>
68 |  *   </restriction>
69 |  * </simpleType>
70 |  * 
71 | * 72 | */ 73 | @XmlEnum 74 | public enum EnumFormats { 75 | 76 | DATE_DDMMYY, DATE_DDMMYYYY, DATE_YYMMDD, DATE_YYYYMMDD, DECIMAL_D, DECIMAL_DD, DECIMAL_DDD, DECIMAL_DDDD; 77 | 78 | public String value() { 79 | return name(); 80 | } 81 | 82 | public static EnumFormats fromValue(String v) { 83 | return valueOf(v); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/language/EnumFormatsTypes.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.XmlEnum; 39 | 40 | /** 41 | * 42 | * 43 | *

44 | * Tipo de formatadores suportados. Usados junto a defini��o de novos 45 | * formatadores. 46 | *

47 | * 48 | * 49 | * 50 | *

51 | * Java class for enumFormatsTypes. 52 | * 53 | *

54 | * The following schema fragment specifies the expected content contained within 55 | * this class. 56 | *

57 | * 58 | *

59 |  * <simpleType name="enumFormatsTypes">
60 |  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
61 |  *     <enumeration value="DATE"/>
62 |  *     <enumeration value="DECIMAL"/>
63 |  *   </restriction>
64 |  * </simpleType>
65 |  * 
66 | * 67 | */ 68 | @XmlEnum 69 | public enum EnumFormatsTypes { 70 | 71 | DATE, DECIMAL; 72 | 73 | public String value() { 74 | return name(); 75 | } 76 | 77 | public static EnumFormatsTypes fromValue(String v) { 78 | return valueOf(v); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/language/EnumPaddings.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.XmlEnum; 39 | 40 | /** 41 | * 42 | * 43 | *

44 | * Preenchimentos suportados por padr�o pelo componente. 45 | *

46 | * 47 | * 48 | * 49 | *

50 | * Java class for enumPaddings. 51 | * 52 | *

53 | * The following schema fragment specifies the expected content contained within 54 | * this class. 55 | *

56 | * 57 | *

58 |  * <simpleType name="enumPaddings">
59 |  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
60 |  *     <enumeration value="ZERO_RIGHT"/>
61 |  *     <enumeration value="ZERO_LEFT"/>
62 |  *     <enumeration value="WHITE_SPACE_RIGHT"/>
63 |  *     <enumeration value="WHITE_SPACE_LEFT"/>
64 |  *   </restriction>
65 |  * </simpleType>
66 |  * 
67 | * 68 | */ 69 | @XmlEnum 70 | public enum EnumPaddings { 71 | 72 | ZERO_RIGHT, ZERO_LEFT, WHITE_SPACE_RIGHT, WHITE_SPACE_LEFT; 73 | 74 | public String value() { 75 | return name(); 76 | } 77 | 78 | public static EnumPaddings fromValue(String v) { 79 | return valueOf(v); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/language/EnumSide.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.XmlEnum; 39 | 40 | /** 41 | * 42 | * 43 | *

44 | * Basicamente s�o defini��es de dire��es de escrita e leitura. 45 | *

46 | * 47 | * 48 | * 49 | *

50 | * Java class for enumSide. 51 | * 52 | *

53 | * The following schema fragment specifies the expected content contained within 54 | * this class. 55 | *

56 | * 57 | *

58 |  * <simpleType name="enumSide">
59 |  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
60 |  *     <enumeration value="LEFT"/>
61 |  *     <enumeration value="RIGHT"/>
62 |  *   </restriction>
63 |  * </simpleType>
64 |  * 
65 | * 66 | */ 67 | @XmlEnum 68 | public enum EnumSide { 69 | 70 | LEFT, RIGHT; 71 | 72 | public String value() { 73 | return name(); 74 | } 75 | 76 | public static EnumSide fromValue(String v) { 77 | return valueOf(v); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/language/EnumTypes.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.XmlEnum; 39 | 40 | /** 41 | * 42 | * 43 | *

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 | *

51 | * Java class for enumTypes. 52 | * 53 | *

54 | * The following schema fragment specifies the expected content contained within 55 | * this class. 56 | *

57 | * 58 | *

59 |  * <simpleType name="enumTypes">
60 |  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
61 |  *     <enumeration value="CHARACTER"/>
62 |  *     <enumeration value="STRING"/>
63 |  *     <enumeration value="INTEGER"/>
64 |  *     <enumeration value="LONG"/>
65 |  *     <enumeration value="FLOAT"/>
66 |  *     <enumeration value="DOUBLE"/>
67 |  *     <enumeration value="BIGDECIMAL"/>
68 |  *     <enumeration value="DATE"/>
69 |  *   </restriction>
70 |  * </simpleType>
71 |  * 
72 | * 73 | */ 74 | @XmlEnum 75 | public enum EnumTypes { 76 | 77 | CHARACTER, STRING, INTEGER, LONG, FLOAT, DOUBLE, BIGDECIMAL, DATE; 78 | 79 | public String value() { 80 | return name(); 81 | } 82 | 83 | public static EnumTypes fromValue(String v) { 84 | return valueOf(v); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/language/MetaField.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.XmlElement; 42 | import javax.xml.bind.annotation.XmlType; 43 | 44 | /** 45 | * 46 | * 47 | *

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 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 | import org.jrimum.texgit.type.component.Side; 44 | 45 | /** 46 | * 47 | * 48 | *

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 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.XmlElement; 41 | import javax.xml.bind.annotation.XmlType; 42 | 43 | /** 44 | * 45 | * 46 | *

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 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 | * Formato utilizado por um Filler (Preenchedor). 48 | *

49 | * 50 | * 51 | * 52 | * 53 | * 54 | */ 55 | @XmlAccessorType(XmlAccessType.FIELD) 56 | @XmlType(name = "MetaFormatter") 57 | public class MetaFormatter { 58 | 59 | @XmlAttribute(required = true) 60 | protected String format; 61 | @XmlAttribute(required = true) 62 | protected EnumFormatsTypes type; 63 | 64 | /** 65 | * Gets the value of the format property. 66 | * 67 | * @return possible object is {@link String } 68 | * 69 | */ 70 | public String getFormat() { 71 | return format; 72 | } 73 | 74 | /** 75 | * Sets the value of the format property. 76 | * 77 | * @param value 78 | * allowed object is {@link String } 79 | * 80 | */ 81 | public void setFormat(String value) { 82 | this.format = value; 83 | } 84 | 85 | /** 86 | * Gets the value of the type property. 87 | * 88 | * @return possible object is {@link EnumFormatsTypes } 89 | * 90 | */ 91 | public EnumFormatsTypes getType() { 92 | return type; 93 | } 94 | 95 | /** 96 | * Sets the value of the type property. 97 | * 98 | * @param value 99 | * allowed object is {@link EnumFormatsTypes } 100 | * 101 | */ 102 | public void setType(EnumFormatsTypes value) { 103 | this.type = value; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/org/jrimum/texgit/language/MetaGroupFields.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.JAXBElement; 42 | import javax.xml.bind.annotation.XmlAccessType; 43 | import javax.xml.bind.annotation.XmlAccessorType; 44 | import javax.xml.bind.annotation.XmlElement; 45 | import javax.xml.bind.annotation.XmlType; 46 | import javax.xml.namespace.QName; 47 | 48 | /** 49 | * 50 | * 51 | *

52 | * Agregado de fields. 53 | *

54 | * 55 | */ 56 | @XmlAccessorType(XmlAccessType.FIELD) 57 | @XmlType(name = "MetaGroupFields", propOrder = { "idType", "fields", 58 | "sequencialNumber" }) 59 | public class MetaGroupFields { 60 | 61 | @XmlElement(name = "IdType", required = true) 62 | protected MetaOrderedField idType; 63 | @XmlElement(name = "Field", required = true) 64 | protected List 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 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 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 | --------------------------------------------------------------------------------