commit inicial

master
fabiorj 2021-12-04 12:20:46 -03:00
parent 2f0cc26fa0
commit 72153fd56a
59 changed files with 7817 additions and 0 deletions

8
jrimum-texgit/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
/bin
/target
.classpath
.DS_Store
.project
.settings

View File

@ -0,0 +1,13 @@
Texgit Changelog
=============================
0.2.3 (2014/02/01) suport bopepo-0.2.3
---------------------------------------
**Improvement**
* #1: Implementação de testes para funcionalidade LineOfFields
0.2.0-SNAPSHOT (2010/12/07) incubation
---------------------------------------

View File

@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,9 @@
Texgit
======
[![Build Status](https://ci-jrimum.rhcloud.com/buildStatus/icon?job=Texgit)](https://ci-jrimum.rhcloud.com)
O projeto Texgit é um componente e framework em Java que facilita a manipulação de arquivos Flat Files (arquivo-texto) através de objetos.
Diversas empresas já usam o Texgit em produção e estão colaborando no Design do componente e da API.

View File

@ -0,0 +1,205 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId>
<artifactId>jrimum-texgit</artifactId>
<name>Projeto Texgit</name>
<version>1.0.0</version>
<description>Projeto open source de componentes de software para o domínio de negócios do Brasil.</description>
<url>http://www.jrimum.org/texgit</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<organization>
<name>Projeto JRimum</name>
<url>http://www.jrimum.org</url>
</organization>
<issueManagement>
<system>GitHub</system>
<url>http://github.com/jrimum/texgit/issues</url>
</issueManagement>
<scm>
<url>http://github.com/jrimum/texgit</url>
</scm>
<developers>
<developer>
<name>Gilmar P. S. L.</name>
<email>gilmatryx@gmail.com</email>
</developer>
<developer>
<name>Misael Barreto</name>
<email>misaelbarreto@gmail.com</email>
</developer>
<developer>
<name>Rômulo Augusto</name>
<email>romulomail@gmail.com</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<profiles>
<profile>
<id>disable-java8-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java15</artifactId>
<version>1.0</version>
</signature>
</configuration>
<executions>
<execution>
<id>animal-sniffer</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jrimum-texgit-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>false</skipTests>
<includes>
<include>org/jrimum/texgit/**/*</include>
</includes>
<excludes>
<exclude>org/jrimum/texgit/excludes/**/*</exclude>
<exclude>org/jrimum/texgit/**/*$*</exclude> <!-- Exclui classes internas anônimas para evitar erros -->
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadoc</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<docfilessubdirs>true</docfilessubdirs>
<show>private</show>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>br.com.rjconsultores</groupId>
<artifactId>jrimum-utilix</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>sun-jaxb-rj</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>sun-jaxb-rj</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>rj-releases</id>
<url>http://52.5.53.15:8081/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>
</project>

View File

@ -0,0 +1,27 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>examples</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>src/examples/java</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*.java</include>
</includes>
</fileSet>
<fileSet>
<directory>src/examples/resources</directory>
<useDefaultExcludes>true</useDefaultExcludes>
<outputDirectory>/resources</outputDirectory>
<includes>
<include>**/**</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@ -0,0 +1,24 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>dep</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
<excludes>
<exclude>commons-lang:commons-lang</exclude>
<exclude>log4j:log4j</exclude>
<exclude>sun-jaxb:jaxb-api</exclude>
<exclude>sun-jaxb:jaxb-impl</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>

View File

@ -0,0 +1,66 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit;
import java.util.Collection;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @param <G>
*/
public interface FlatFile<G extends Record> extends TextListStream {
// Registros individuais
public G createRecord(String idType);
public FlatFile<G> addRecord(G record);
public G getRecord(String idName);
public G removeRecord(String idName);
// Grupos de Registros (Registros que se repetem)
public FlatFile<G> addRecords(String idName, Collection<G> records);
public FlatFile<G> setRecords(String idName, Collection<G> records);
public Collection<G> getRecords(String idName);
// Todos os Registros
public FlatFile<G> addAllRecords(Collection<G> records);
public FlatFile<G> setAllRecords(Collection<G> records);
public Collection<G> getAllRecords();
}

View File

@ -0,0 +1,69 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 30/03/2008 - 18:17:10
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 30/03/2008 - 18:17:10
*
*/
package org.jrimum.texgit;
import java.io.Serializable;
/**
* <p>
* Interface genérica e representativa de coisas que necessitam de operações de
* fluxo de escrita e leitura.
* </p>
*
* @author <a href=http://gilmatryx.googlepages.com/>Gilmar P.S.L.</a>
*
* @since 0.2
*
* @version 0.2
*/
public interface ReadWriteStream<G> extends Serializable {
/**
* <p>
* Escreve o tipo infomado.
* </p>
*
* @return Um valor no mesmo tipo do tipo parametrizado
* @since 0.2
*/
G write();
/**
* <p>
* Lê o tipo informado.
* </p>
*
* @param g - Valor a ser lido
*
* @since 0.2
*/
void read(G g);
}

View File

@ -0,0 +1,46 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit;
import java.util.List;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public interface Record extends TextStream {
public <G> Record setValue(String fieldName, G value);
public <G> G getValue(String fieldName);
public Record addInnerRecord(Record record);
public List<Record> getInnerRecords();
}

View File

@ -0,0 +1,126 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.jrimum.utilix.Objects.isNotNull;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import org.jrimum.texgit.engine.TexgitManager;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public final class Texgit {
public static final FlatFile<Record> createFlatFile(String xmlDefFilePath)
throws TexgitException {
try {
if (isNotBlank(xmlDefFilePath))
return createFlatFile(new File(xmlDefFilePath));
} catch (Exception e) {
throw new TexgitException(e);
}
return null;
}
public static final FlatFile<Record> createFlatFile(File xmlDefFile)
throws TexgitException {
try {
if (isNotNull(xmlDefFile)) {
return createFlatFile(new FileInputStream(xmlDefFile));
}
} catch (Exception e) {
throw new TexgitException(e);
}
return null;
}
public static final FlatFile<Record> createFlatFile(URL xmlDefUrl)
throws TexgitException {
try {
if (isNotNull(xmlDefUrl)) {
return TexgitManager.buildFlatFile(xmlDefUrl.openStream());
}
} catch (Exception e) {
throw new TexgitException(e);
}
return null;
}
public static final FlatFile<Record> createFlatFile(byte[] xmlDefBytes)
throws TexgitException {
try {
if (isNotNull(xmlDefBytes)) {
return TexgitManager.buildFlatFile(new ByteArrayInputStream(xmlDefBytes));
}
} catch (Exception e) {
throw new TexgitException(e);
}
return null;
}
public static final FlatFile<Record> createFlatFile(InputStream xmlDefStream)
throws TexgitException {
if (isNotNull(xmlDefStream)) {
return TexgitManager.buildFlatFile(xmlDefStream);
}
return null;
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit;
/**
*
* <p>
* Invólucro para exceções ocorridas no componente.
* </p>
*
* @author <a href="http://gilmatryx.googlepages.com">Gilmar P.S.L.</a>
*
* */
@SuppressWarnings("serial")
public class TexgitException extends RuntimeException {
/**
*
*/
public TexgitException() {
super();
}
/**
* @param arg0
* @param arg1
*/
public TexgitException(String arg0, Throwable arg1) {
super(arg0, arg1);
}
/**
* @param arg0
*/
public TexgitException(String arg0) {
super(arg0);
}
/**
* @param arg0
*/
public TexgitException(Throwable arg0) {
super(arg0);
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit;
import java.util.List;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public interface TextListStream extends ReadWriteStream<List<String>> {
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 30/03/2008 - 18:17:20
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 30/03/2008 - 18:17:20
*
*/
package org.jrimum.texgit;
/**
* <p>Interface usada para objetos com serviços de leitura e escrita de textos.</p>
*
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L</a>
* @author <a href="mailto:misaelbarreto@gmail.com">Misael Barreto</a>
* @author <a href="mailto:romulomail@gmail.com">Rômulo Augusto</a>
* @author <a href="http://www.nordestefomento.com.br">Nordeste Fomento
* Mercantil</a>
*
* @since 0.2
*
* @version 0.2
*/
public interface TextStream extends ReadWriteStream<String> {
}

View File

@ -0,0 +1,263 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.apache.commons.lang.StringUtils.countMatches;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.jrimum.utilix.Objects.isNotNull;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.Format;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.jrimum.texgit.TexgitException;
import org.jrimum.texgit.language.EnumFormats;
import org.jrimum.texgit.language.EnumFormatsTypes;
import org.jrimum.texgit.language.MetaField;
import org.jrimum.texgit.type.Filler;
import org.jrimum.texgit.type.component.Fillers;
import org.jrimum.texgit.type.component.FixedField;
import org.jrimum.texgit.type.component.Side;
import org.jrimum.utilix.Dates;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
class FixedFieldBuilder {
private final static String BASE_DECIMAL_FORMAT = "0.";
static FixedField<?> build(MetaField metaField) {
FixedField<?> fixedField = null;
try {
fixedField = getInstance(metaField);
} catch (ParseException e) {
throw new TexgitException("Field: " + metaField.getName(), e);
}
return fixedField;
}
private static FixedField<?> getInstance(MetaField metaField)
throws ParseException {
FixedField<?> fField = null;
Format formatter = getFormater(metaField);
switch (metaField.getType()) {
case CHARACTER:
FixedField<Character> fCHR = new FixedField<Character>();
if (isNotBlank(metaField.getValue()))
if(metaField.getValue().length() == 1)
fCHR.setValue(metaField.getValue().charAt(0));
else
throw new IllegalArgumentException("Tipo character deve ter apenas 1!");
else
fCHR.setValue(' ');
fField = fCHR;
break;
case STRING:
FixedField<String> fSTR = new FixedField<String>();
if (isNotBlank(metaField.getValue()))
fSTR.setValue(metaField.getValue());
else
fSTR.setValue(EMPTY);
fField = fSTR;
break;
case INTEGER:
FixedField<Integer> fINT = new FixedField<Integer>();
if (isNotBlank(metaField.getValue()))
fINT.setValue(Integer.parseInt(metaField.getValue()));
else
fINT.setValue(Integer.valueOf(0));
fField = fINT;
break;
case LONG:
FixedField<Long> fLNG = new FixedField<Long>();
if (isNotBlank(metaField.getValue()))
fLNG.setValue(Long.parseLong(metaField.getValue()));
else
fLNG.setValue(Long.valueOf(0));
fField = fLNG;
break;
case FLOAT:
FixedField<Float> fFLT = new FixedField<Float>();
if (isNotBlank(metaField.getValue()))
fFLT.setValue(Float.parseFloat(metaField.getValue()));
else
fFLT.setValue(Float.valueOf(0));
fField = fFLT;
break;
case DOUBLE:
FixedField<Double> fDBE = new FixedField<Double>();
if (isNotBlank(metaField.getValue()))
fDBE.setValue(Double.parseDouble(metaField.getValue()));
else
fDBE.setValue(Double.valueOf(0));
fField = fDBE;
break;
case BIGDECIMAL:
FixedField<BigDecimal> fBDL = new FixedField<BigDecimal>();
if (isNotBlank(metaField.getValue()))
fBDL.setValue(new BigDecimal(DecimalFormat.class
.cast(formatter).parse(metaField.getValue())
.doubleValue()));
else
fBDL.setValue(BigDecimal.ZERO);
fField = fBDL;
break;
case DATE:
FixedField<Date> fDTE = new FixedField<Date>();
if (isNotBlank(metaField.getValue())){
fDTE.setValue(DateFormat.class.cast(formatter).parse(
metaField.getValue()));
}
else{
fDTE.setValue(Dates.invalidDate());
}
fField = fDTE;
break;
}
fField.setName(metaField.getName());
fField.setFixedLength(metaField.getLength());
fField.setFiller(getFiller(metaField));
fField.setBlankAccepted(metaField.isBlankAccepted());
fField.setTruncate(metaField.isTruncate());
if(isNotNull(formatter))
fField.setFormatter(formatter);
return fField;
}
private static Filler getFiller(MetaField metaField) {
Filler filler = null;
if (isNotNull(metaField.getFiller())) {
org.jrimum.texgit.type.component.Filler<String> filr = new org.jrimum.texgit.type.component.Filler<String>();
filr.setPadding(metaField.getFiller().getPadding());
filr.setSideToFill(Side.valueOf(metaField.getFiller()
.getSideToFill().name()));
filler = filr;
} else {
filler = Fillers.valueOf(metaField.getPadding().name());
}
return filler;
}
private static Format getFormater(MetaField metaField) {
Format formatter = null;
if (isNotNull(metaField.getFormatter())) {
formatter = buildFormat(metaField.getFormatter().getFormat(),
metaField.getFormatter().getType());
} else {
if(isNotNull(metaField.getFormat())){
EnumFormats format = metaField.getFormat();
EnumFormatsTypes type = EnumFormatsTypes.valueOf(format.name()
.split("_")[0]);
formatter = buildFormat(buildFormat(format, type), type);
}
}
return formatter;
}
private static Format buildFormat(String strFormat, EnumFormatsTypes type) {
Format format = null;
switch (type) {
case DATE:
format = new SimpleDateFormat(strFormat);
break;
case DECIMAL:
format = new DecimalFormat(strFormat);
break;
}
return format;
}
private static String buildFormat(EnumFormats format, EnumFormatsTypes type) {
String strFormat = EMPTY;
/*
* DATE_DDMMYY, DATE_DDMMYYYY, DATE_YYMMDD, DATE_YYYYMMDD,
* DECIMAL_D,DECIMAL_DD, DECIMAL_DDD, DECIMAL_DDDD;
*/
String defFormat = format.name().split("_")[1];
switch (type) {
case DATE:
defFormat = defFormat.replaceAll("D", "d");
strFormat = defFormat.replaceAll("Y", "y");
break;
case DECIMAL:
int lengthToFill = BASE_DECIMAL_FORMAT.length()
+ countMatches(defFormat, "D");
strFormat = Fillers.ZERO_RIGHT.fill(
BASE_DECIMAL_FORMAT, lengthToFill);
break;
}
return strFormat;
}
}

View File

@ -0,0 +1,82 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import static org.jrimum.utilix.Objects.isNotNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jrimum.texgit.language.MetaFlatFile;
import org.jrimum.texgit.language.MetaRecord;
import org.jrimum.texgit.type.component.FlatFile;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public class FlatFileBuilder {
static FlatFile build(MetaFlatFile mFlatFile) {
FlatFile ff = null;
List<MetaRecord> metaRecords = mFlatFile.getGroupOfRecords().getRecords();
ff = new FlatFile(new RecordFactory(metaRecords));
Set<String> repitables = new HashSet<String>();
List<String> recordsOrder = new ArrayList<String>();
if (isNotNull(metaRecords)) {
if (!metaRecords.isEmpty()) {
for (MetaRecord mRec : metaRecords) {
recordsOrder.add(mRec.getName());
if (mRec.isRepeatable())
repitables.add(mRec.getName());
}
}
}
ff.setRecordsOrder(recordsOrder);
ff.setRepitablesRecords(repitables);
return ff;
}
}

View File

@ -0,0 +1,137 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import static org.jrimum.utilix.Objects.isNotNull;
import static org.jrimum.utilix.Objects.isNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.jrimum.texgit.language.MetaField;
import org.jrimum.texgit.language.MetaOrderedField;
import org.jrimum.texgit.language.MetaRecord;
import org.jrimum.texgit.type.component.FixedField;
import org.jrimum.texgit.type.component.Record;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
class RecordBuilder {
@SuppressWarnings("unchecked")
static Record build(MetaRecord metaRecord) {
int strLength = getStringLength(metaRecord.getGroupOfFields().getFields());
int fldSize = metaRecord.getGroupOfFields().getFields().size();
MetaOrderedField id = metaRecord.getGroupOfFields().getIdType();
MetaOrderedField sequencialNumber = metaRecord.getGroupOfFields().getSequencialNumber();
if(isNotNull(id)){
fldSize += 1;
strLength += id.getLength();
}
if(isNotNull(sequencialNumber)){
fldSize += 1;
strLength += sequencialNumber.getLength();
}
Record record = new Record(strLength,fldSize);
record.setName(metaRecord.getName());
record.setDescription(metaRecord.getDescription());
/*
* getPossition eh de 1 a X
* e nao de 0 a X.
*/
if(isNotNull(id)){
record.setIdType((FixedField<String>) FixedFieldBuilder.build(id));
record.set(id.getPosition()-1, record.getIdType());
}
if(isNotNull(sequencialNumber)){
record.setSequencialNumber((FixedField<Long>) FixedFieldBuilder.build(sequencialNumber));
record.set(sequencialNumber.getPosition()-1,record.getSequencialNumber());
}
List<MetaField> fields = metaRecord.getGroupOfFields().getFields();
/*
* As somas sao para caso id ou sequencia jah
* estejam na devida posicao.
*/
for(MetaField mField : fields){
if(isNull(record.get(fields.indexOf(mField))))
record.set(fields.indexOf(mField), FixedFieldBuilder.build(mField));
else
if(isNull(record.get(fields.indexOf(mField)+1)))
record.set(fields.indexOf(mField) + 1, FixedFieldBuilder.build(mField));
else
record.set(fields.indexOf(mField) + 2, FixedFieldBuilder.build(mField));
}
// innerRecords
if (isNotNull(metaRecord.getGroupOfInnerRecords())){
record.setHeadOfGroup(true);
record.setDeclaredInnerRecords(new ArrayList<String>(metaRecord.getGroupOfInnerRecords().getRecords().size()));
record.setRepitablesRecords(new HashSet<String>());
List<MetaRecord> metaInnerRecords = metaRecord.getGroupOfInnerRecords().getRecords();
for(MetaRecord mRecord : metaInnerRecords){
record.getDeclaredInnerRecords().add(mRecord.getName());
if(mRecord.isRepeatable())
record.getRepitablesRecords().add(mRecord.getName());
}
}else
record.setHeadOfGroup(false);
return record;
}
private static int getStringLength(List<MetaField> fields){
int length = 0;
for(MetaField mField : fields)
length += mField.getLength();
return length;
}
}

View File

@ -0,0 +1,100 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.jrimum.utilix.Objects.isNotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jrimum.texgit.language.MetaRecord;
import org.jrimum.texgit.type.component.Record;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public class RecordFactory implements org.jrimum.texgit.type.component.RecordFactory<Record> {
private Map<String, MetaRecord> name_record;
RecordFactory(List<MetaRecord> metaRecords) {
if (isNotNull(metaRecords)) {
if (!metaRecords.isEmpty()) {
name_record = new HashMap<String, MetaRecord>(metaRecords
.size());
for (MetaRecord mRecord : metaRecords) {
name_record.put(mRecord.getName(), mRecord);
if (isNotNull(mRecord.getGroupOfInnerRecords()))
loadInnerRecords(name_record, mRecord
.getGroupOfInnerRecords().getRecords());
}
}
}
}
private void loadInnerRecords(Map<String, MetaRecord> name_record,
List<MetaRecord> innerMetaRecords) {
if (isNotNull(innerMetaRecords)) {
if (!innerMetaRecords.isEmpty()) {
for (MetaRecord iMetaRecord : innerMetaRecords) {
name_record.put(iMetaRecord.getName(), iMetaRecord);
if (isNotNull(iMetaRecord.getGroupOfInnerRecords()))
loadInnerRecords(name_record, iMetaRecord
.getGroupOfInnerRecords().getRecords());
}
}
}
}
public Record create(String name) {
Record record = null;
if (isNotBlank(name))
if (name_record.containsKey(name))
record = RecordBuilder.build(name_record.get(name));
return record;
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import org.jrimum.texgit.TexgitException;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
@SuppressWarnings("serial")
public class TexgitLanguageException extends TexgitException {
/**
*
*/
public TexgitLanguageException() {
super();
}
/**
* @param arg0
* @param arg1
*/
public TexgitLanguageException(String arg0, Throwable arg1) {
super(arg0, arg1);
}
/**
* @param arg0
*/
public TexgitLanguageException(String arg0) {
super(arg0);
}
/**
* @param arg0
*/
public TexgitLanguageException(Throwable arg0) {
super(arg0);
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import java.io.InputStream;
import org.jrimum.texgit.FlatFile;
import org.jrimum.texgit.Record;
import org.jrimum.texgit.TexgitException;
import org.jrimum.texgit.language.MetaTexgit;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public class TexgitManager {
public static FlatFile<org.jrimum.texgit.Record> buildFlatFile(InputStream xmlDefStream) {
FlatFile<Record> iFlatFile = null;
try {
MetaTexgit tgMeta = TexgitXmlReader.parse(xmlDefStream);
iFlatFile = FlatFileBuilder.build(tgMeta.getFlatFile());
} catch (Exception e) {
throw new TexgitException(e);
}
return iFlatFile;
}
}

View File

@ -0,0 +1,68 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.ValidationEventLocator;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
class TexgitSchemaValidator implements ValidationEventHandler {
public boolean handleEvent(ValidationEvent event) {
boolean handled = false;
if (event.getSeverity() == ValidationEvent.WARNING) {
System.err.println(getMensagem("ATENÇÃO LAYOUT INCONSISTENTE!\n",
event));
handled = true;
} else
// ERROR
System.err.println(getMensagem("ERRO NO LAYOUT!\n", event));
return handled;
}
private String getMensagem(String msg, ValidationEvent event) {
ValidationEventLocator local = event.getLocator();
return msg +
"Linha { " + local.getLineNumber() + " } " + "Conluna [ "
+ local.getColumnNumber() + " ] " + event.getMessage();
}
}

View File

@ -0,0 +1,94 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.engine;
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
import static org.jrimum.utilix.Objects.isNotNull;
import java.io.InputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import org.jrimum.texgit.Texgit;
import org.jrimum.texgit.TexgitException;
import org.jrimum.texgit.language.MetaTexgit;
import org.jrimum.utilix.ClassLoaders;
import org.xml.sax.SAXException;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
class TexgitXmlReader {
public static MetaTexgit parse(InputStream xmlDefStream) throws TexgitException {
MetaTexgit txg = null;
if (isNotNull(xmlDefStream)) {
try {
JAXBContext aJaxbContext = JAXBContext
.newInstance(MetaTexgit.class);
Unmarshaller aUnmarshaller = aJaxbContext.createUnmarshaller();
SchemaFactory aSchemaFactory = SchemaFactory
.newInstance(W3C_XML_SCHEMA_NS_URI);
Schema schema = aSchemaFactory.newSchema(ClassLoaders.getResource("TexgitSchema.xsd",Texgit.class));
aUnmarshaller.setSchema(schema);
aUnmarshaller.setEventHandler(new TexgitSchemaValidator());
txg = (MetaTexgit) aUnmarshaller.unmarshal(xmlDefStream);
} catch (SAXException e) {
throw new TexgitLanguageException(e);
} catch (JAXBException e) {
throw new TexgitLanguageException(e);
}
}
return txg;
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlEnum;
/**
*
*
* <p>
* Formatos pr<EFBFBD> definidos suportados pelo componente.
* </p>
*
*
*
* <p>
* Java class for enumFormats.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
* <p>
*
* <pre>
* &lt;simpleType name=&quot;enumFormats&quot;&gt;
* &lt;restriction base=&quot;{http://www.w3.org/2001/XMLSchema}string&quot;&gt;
* &lt;enumeration value=&quot;DATE_DDMMYY&quot;/&gt;
* &lt;enumeration value=&quot;DATE_DDMMYYYY&quot;/&gt;
* &lt;enumeration value=&quot;DATE_YYMMDD&quot;/&gt;
* &lt;enumeration value=&quot;DATE_YYYYMMDD&quot;/&gt;
* &lt;enumeration value=&quot;DECIMAL_D&quot;/&gt;
* &lt;enumeration value=&quot;DECIMAL_DD&quot;/&gt;
* &lt;enumeration value=&quot;DECIMAL_DDD&quot;/&gt;
* &lt;enumeration value=&quot;DECIMAL_DDDD&quot;/&gt;
* &lt;/restriction&gt;
* &lt;/simpleType&gt;
* </pre>
*
*/
@XmlEnum
public enum EnumFormats {
DATE_DDMMYY, DATE_DDMMYYYY, DATE_YYMMDD, DATE_YYYYMMDD, DECIMAL_D, DECIMAL_DD, DECIMAL_DDD, DECIMAL_DDDD;
public String value() {
return name();
}
public static EnumFormats fromValue(String v) {
return valueOf(v);
}
}

View File

@ -0,0 +1,81 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlEnum;
/**
*
*
* <p>
* Tipo de formatadores suportados. Usados junto a defini<EFBFBD><EFBFBD>o de novos
* formatadores.
* </p>
*
*
*
* <p>
* Java class for enumFormatsTypes.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
* <p>
*
* <pre>
* &lt;simpleType name=&quot;enumFormatsTypes&quot;&gt;
* &lt;restriction base=&quot;{http://www.w3.org/2001/XMLSchema}string&quot;&gt;
* &lt;enumeration value=&quot;DATE&quot;/&gt;
* &lt;enumeration value=&quot;DECIMAL&quot;/&gt;
* &lt;/restriction&gt;
* &lt;/simpleType&gt;
* </pre>
*
*/
@XmlEnum
public enum EnumFormatsTypes {
DATE, DECIMAL;
public String value() {
return name();
}
public static EnumFormatsTypes fromValue(String v) {
return valueOf(v);
}
}

View File

@ -0,0 +1,82 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlEnum;
/**
*
*
* <p>
* Preenchimentos suportados por padr<EFBFBD>o pelo componente.
* </p>
*
*
*
* <p>
* Java class for enumPaddings.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
* <p>
*
* <pre>
* &lt;simpleType name=&quot;enumPaddings&quot;&gt;
* &lt;restriction base=&quot;{http://www.w3.org/2001/XMLSchema}string&quot;&gt;
* &lt;enumeration value=&quot;ZERO_RIGHT&quot;/&gt;
* &lt;enumeration value=&quot;ZERO_LEFT&quot;/&gt;
* &lt;enumeration value=&quot;WHITE_SPACE_RIGHT&quot;/&gt;
* &lt;enumeration value=&quot;WHITE_SPACE_LEFT&quot;/&gt;
* &lt;/restriction&gt;
* &lt;/simpleType&gt;
* </pre>
*
*/
@XmlEnum
public enum EnumPaddings {
ZERO_RIGHT, ZERO_LEFT, WHITE_SPACE_RIGHT, WHITE_SPACE_LEFT;
public String value() {
return name();
}
public static EnumPaddings fromValue(String v) {
return valueOf(v);
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlEnum;
/**
*
*
* <p>
* Basicamente s<EFBFBD>o defini<EFBFBD><EFBFBD>es de dire<EFBFBD><EFBFBD>es de escrita e leitura.
* </p>
*
*
*
* <p>
* Java class for enumSide.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
* <p>
*
* <pre>
* &lt;simpleType name=&quot;enumSide&quot;&gt;
* &lt;restriction base=&quot;{http://www.w3.org/2001/XMLSchema}string&quot;&gt;
* &lt;enumeration value=&quot;LEFT&quot;/&gt;
* &lt;enumeration value=&quot;RIGHT&quot;/&gt;
* &lt;/restriction&gt;
* &lt;/simpleType&gt;
* </pre>
*
*/
@XmlEnum
public enum EnumSide {
LEFT, RIGHT;
public String value() {
return name();
}
public static EnumSide fromValue(String v) {
return valueOf(v);
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlEnum;
/**
*
*
* <p>
* Tipos usados para obten<EFBFBD><EFBFBD>o dos campos de texto para java. No caso representa
* os tipos java poss<EFBFBD>veis para um campo.
* </p>
*
*
*
* <p>
* Java class for enumTypes.
*
* <p>
* The following schema fragment specifies the expected content contained within
* this class.
* <p>
*
* <pre>
* &lt;simpleType name=&quot;enumTypes&quot;&gt;
* &lt;restriction base=&quot;{http://www.w3.org/2001/XMLSchema}string&quot;&gt;
* &lt;enumeration value=&quot;CHARACTER&quot;/&gt;
* &lt;enumeration value=&quot;STRING&quot;/&gt;
* &lt;enumeration value=&quot;INTEGER&quot;/&gt;
* &lt;enumeration value=&quot;LONG&quot;/&gt;
* &lt;enumeration value=&quot;FLOAT&quot;/&gt;
* &lt;enumeration value=&quot;DOUBLE&quot;/&gt;
* &lt;enumeration value=&quot;BIGDECIMAL&quot;/&gt;
* &lt;enumeration value=&quot;DATE&quot;/&gt;
* &lt;/restriction&gt;
* &lt;/simpleType&gt;
* </pre>
*
*/
@XmlEnum
public enum EnumTypes {
CHARACTER, STRING, INTEGER, LONG, FLOAT, DOUBLE, BIGDECIMAL, DATE;
public String value() {
return name();
}
public static EnumTypes fromValue(String v) {
return valueOf(v);
}
}

View File

@ -0,0 +1,309 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Field <EFBFBD> a unidade b<EFBFBD>sica de informa<EFBFBD><EFBFBD>o de um registro, um field est<EFBFBD> para um
* registro assim como uma coluna de banco de dados est<EFBFBD> para uma tabela.
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaField", propOrder = {
})
public class MetaField {
@XmlElement(name = "Filler")
protected MetaFiller filler;
@XmlElement(name = "Formatter")
protected MetaFormatter formatter;
@XmlAttribute
protected Boolean blankAccepted;
@XmlAttribute
protected Boolean truncate;
@XmlAttribute
protected EnumFormats format;
@XmlAttribute(required = true)
protected int length;
@XmlAttribute(required = true)
protected String name;
@XmlAttribute
protected EnumPaddings padding;
@XmlAttribute
protected EnumTypes type;
@XmlAttribute
protected String value;
/**
* Gets the value of the filler property.
*
* @return possible object is {@link MetaFiller }
*
*/
public MetaFiller getFiller() {
return filler;
}
/**
* Sets the value of the filler property.
*
* @param value
* allowed object is {@link MetaFiller }
*
*/
public void setFiller(MetaFiller value) {
this.filler = value;
}
/**
* Gets the value of the formatter property.
*
* @return possible object is {@link MetaFormatter }
*
*/
public MetaFormatter getFormatter() {
return formatter;
}
/**
* Sets the value of the formatter property.
*
* @param value
* allowed object is {@link MetaFormatter }
*
*/
public void setFormatter(MetaFormatter value) {
this.formatter = value;
}
/**
* Gets the value of the blankAccepted property.
*
* @return possible object is {@link Boolean }
*
*/
public boolean isBlankAccepted() {
if (blankAccepted == null) {
return false;
} else {
return blankAccepted;
}
}
/**
* Sets the value of the blankAccepted property.
*
* @param value
* allowed object is {@link Boolean }
*
*/
public void setBlankAccepted(Boolean value) {
this.blankAccepted = value;
}
/**
* Gets the value of the truncate property.
*
* @return possible object is {@link Boolean }
*
*/
public boolean isTruncate() {
if (truncate == null) {
return false;
} else {
return truncate;
}
}
/**
* Sets the value of the blankAccepted property.
*
* @param value
* allowed object is {@link Boolean }
*
*/
public void setTruncate(Boolean value) {
this.truncate = value;
}
/**
* Gets the value of the format property.
*
* @return possible object is {@link EnumFormats }
*
*/
public EnumFormats getFormat() {
return format;
}
/**
* Sets the value of the format property.
*
* @param value
* allowed object is {@link EnumFormats }
*
*/
public void setFormat(EnumFormats value) {
this.format = value;
}
/**
* Gets the value of the length property.
*
*/
public int getLength() {
return length;
}
/**
* Sets the value of the length property.
*
*/
public void setLength(int value) {
this.length = value;
}
/**
* Gets the value of the name property.
*
* @return possible object is {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Gets the value of the padding property.
*
* @return possible object is {@link EnumPaddings }
*
*/
public EnumPaddings getPadding() {
if (padding == null) {
return EnumPaddings.WHITE_SPACE_RIGHT;
} else {
return padding;
}
}
/**
* Sets the value of the padding property.
*
* @param value
* allowed object is {@link EnumPaddings }
*
*/
public void setPadding(EnumPaddings value) {
this.padding = value;
}
/**
* Gets the value of the type property.
*
* @return possible object is {@link EnumTypes }
*
*/
public EnumTypes getType() {
if (type == null) {
return EnumTypes.STRING;
} else {
return type;
}
}
/**
* Sets the value of the type property.
*
* @param value
* allowed object is {@link EnumTypes }
*
*/
public void setType(EnumTypes value) {
this.type = value;
}
/**
* Gets the value of the value property.
*
* @return possible object is {@link String }
*
*/
public String getValue() {
if (value == null) {
return " ";
} else {
return value;
}
}
/**
* Sets the value of the value property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,113 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import org.jrimum.texgit.type.component.Side;
/**
*
*
* <p>
* Instrumento utilizado para preencher um field com um formato e caracteres pr<EFBFBD>
* definidos.
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaFiller")
public class MetaFiller {
@XmlAttribute(required = true)
protected String padding;
@XmlAttribute
protected EnumSide sideToFill;
/**
* Gets the value of the padding property.
*
* @return possible object is {@link String }
*
*/
public String getPadding() {
return padding;
}
/**
* Sets the value of the padding property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setPadding(String value) {
this.padding = value;
}
/**
* Gets the value of the sideToFill property.
*
* @return possible object is {@link Side }
*
*/
public EnumSide getSideToFill() {
if (sideToFill == null) {
return EnumSide.LEFT;
} else {
return sideToFill;
}
}
/**
* Sets the value of the sideToFill property.
*
* @param value
* allowed object is {@link Side }
*
*/
public void setSideToFill(EnumSide value) {
this.sideToFill = value;
}
}

View File

@ -0,0 +1,106 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Flat File <EFBFBD> um tipo de arquivo texto com informa<EFBFBD><EFBFBD>es estruturadas com base em
* formata<EFBFBD><EFBFBD>es e estruturas pr<EFBFBD> definidas. veja mais em (link).
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaFlatFile", propOrder = { "layout", "groupOfRecords" })
public class MetaFlatFile {
protected MetaLayout layout;
@XmlElement(name = "GroupOfRecords", required = true)
protected MetaGroupRecords groupOfRecords;
/**
* Gets the value of the layout property.
*
* @return possible object is {@link MetaLayout }
*
*/
public MetaLayout getLayout() {
return layout;
}
/**
* Sets the value of the layout property.
*
* @param value
* allowed object is {@link MetaLayout }
*
*/
public void setLayout(MetaLayout value) {
this.layout = value;
}
/**
* Gets the value of the groupOfRecords property.
*
* @return possible object is {@link MetaGroupRecords }
*
*/
public MetaGroupRecords getGroupOfRecords() {
return groupOfRecords;
}
/**
* Sets the value of the groupOfRecords property.
*
* @param value
* allowed object is {@link MetaGroupRecords }
*
*/
public void setGroupOfRecords(MetaGroupRecords value) {
this.groupOfRecords = value;
}
}

View File

@ -0,0 +1,106 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Formato utilizado por um Filler (Preenchedor).
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaFormatter")
public class MetaFormatter {
@XmlAttribute(required = true)
protected String format;
@XmlAttribute(required = true)
protected EnumFormatsTypes type;
/**
* Gets the value of the format property.
*
* @return possible object is {@link String }
*
*/
public String getFormat() {
return format;
}
/**
* Sets the value of the format property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setFormat(String value) {
this.format = value;
}
/**
* Gets the value of the type property.
*
* @return possible object is {@link EnumFormatsTypes }
*
*/
public EnumFormatsTypes getType() {
return type;
}
/**
* Sets the value of the type property.
*
* @param value
* allowed object is {@link EnumFormatsTypes }
*
*/
public void setType(EnumFormatsTypes value) {
this.type = value;
}
}

View File

@ -0,0 +1,172 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
/**
*
*
* <p>
* Agregado de fields.
* </p>
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaGroupFields", propOrder = { "idType", "fields",
"sequencialNumber" })
public class MetaGroupFields {
@XmlElement(name = "IdType", required = true)
protected MetaOrderedField idType;
@XmlElement(name = "Field", required = true)
protected List<MetaField> fields;
@XmlElement(name = "SequencialNumber")
protected MetaOrderedField sequencialNumber;
/**
* Gets the value of the idType property.
*
* @return possible object is {@link MetaOrderedField }
*
*/
public MetaOrderedField getIdType() {
return idType;
}
/**
* Sets the value of the idType property.
*
* @param value
* allowed object is {@link MetaOrderedField }
*
*/
public void setIdType(MetaOrderedField value) {
this.idType = value;
}
/**
* Gets the value of the fields property.
*
* <p>
* This accessor method returns a reference to the live list, not a
* snapshot. Therefore any modification you make to the returned list will
* be present inside the JAXB object. This is why there is not a
* <CODE>set</CODE> method for the fields property.
*
* <p>
* For example, to add a new item, do as follows:
*
* <pre>
* getFields().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link MetaField }
*
*
*/
public List<MetaField> getFields() {
if (fields == null) {
fields = new ArrayList<MetaField>();
}
return this.fields;
}
/**
* Gets the value of the sequencialNumber property.
*
* @return possible object is {@link MetaOrderedField }
*
*/
public MetaOrderedField getSequencialNumber() {
return sequencialNumber;
}
/**
* Sets the value of the sequencialNumber property.
*
* @param value
* allowed object is {@link MetaOrderedField }
*
*/
public void setSequencialNumber(MetaOrderedField value) {
this.sequencialNumber = value;
}
public static class IdType extends JAXBElement<MetaOrderedField> {
/**
* {@code serialVersionUID = -8934480908648452108L}
*/
private static final long serialVersionUID = -8934480908648452108L;
protected final static QName NAME = new QName("", "IdType");
public IdType(MetaOrderedField value) {
super(NAME, ((Class<MetaOrderedField>) MetaOrderedField.class),
MetaGroupFields.class, value);
}
}
public static class SequencialNumber extends JAXBElement<MetaOrderedField> {
/**
* {@code serialVersionUID = 3923837730914132777L}
*/
private static final long serialVersionUID = 3923837730914132777L;
protected final static QName NAME = new QName("", "SequencialNumber");
public SequencialNumber(MetaOrderedField value) {
super(NAME, ((Class<MetaOrderedField>) MetaOrderedField.class),
MetaGroupFields.class, value);
}
}
}

View File

@ -0,0 +1,95 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Conjunto de records de um flatfile ou relacionados a um outro record.
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaGroupRecords", propOrder = { "records" })
public class MetaGroupRecords {
@XmlElement(name = "Record", required = true)
protected List<MetaRecord> records;
/**
* Gets the value of the records property.
*
* <p>
* This accessor method returns a reference to the live list, not a
* snapshot. Therefore any modification you make to the returned list will
* be present inside the JAXB object. This is why there is not a
* <CODE>set</CODE> method for the records property.
*
* <p>
* For example, to add a new item, do as follows:
*
* <pre>
* getRecords().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link MetaRecord }
*
*
*/
public List<MetaRecord> getRecords() {
if (records == null) {
records = new ArrayList<MetaRecord>();
}
return this.records;
}
}

View File

@ -0,0 +1,127 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Tags para informar o layout do flafile definido.
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaLayout", propOrder = {
})
public class MetaLayout {
protected String name;
protected String version;
protected String description;
/**
* Gets the value of the name property.
*
* @return possible object is {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Gets the value of the version property.
*
* @return possible object is {@link String }
*
*/
public String getVersion() {
return version;
}
/**
* Sets the value of the version property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setVersion(String value) {
this.version = value;
}
/**
* Gets the value of the description property.
*
* @return possible object is {@link String }
*
*/
public String getDescription() {
return description;
}
/**
* Sets the value of the description property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setDescription(String value) {
this.description = value;
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Para defini<EFBFBD><EFBFBD>o da posi<EFBFBD><EFBFBD>o.
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaOrderedField")
public class MetaOrderedField extends MetaField {
@XmlAttribute(required = true)
protected int position;
/**
* Gets the value of the position property.
*
*/
public int getPosition() {
return position;
}
/**
* Sets the value of the position property.
*
*/
public void setPosition(int value) {
this.position = value;
}
}

View File

@ -0,0 +1,183 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Uma esp<EFBFBD>cie de container de fields numa forma mais simples, usualmente <EFBFBD>
* conhecido como Registro ou Bloco.
* </p>
*
*
*
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaRecord", propOrder = { "groupOfFields",
"groupOfInnerRecords" })
public class MetaRecord {
@XmlElement(name = "GroupOfFields", required = true)
protected MetaGroupFields groupOfFields;
@XmlElement(name = "GroupOfInnerRecords")
protected MetaGroupRecords groupOfInnerRecords;
@XmlAttribute
protected String description;
@XmlAttribute
protected String name;
@XmlAttribute
protected Boolean repeatable;
/**
* Gets the value of the groupOfFields property.
*
* @return possible object is {@link MetaGroupFields }
*
*/
public MetaGroupFields getGroupOfFields() {
return groupOfFields;
}
/**
* Sets the value of the groupOfFields property.
*
* @param value
* allowed object is {@link MetaGroupFields }
*
*/
public void setGroupOfFields(MetaGroupFields value) {
this.groupOfFields = value;
}
/**
* Gets the value of the groupOfInnerRecords property.
*
* @return possible object is {@link MetaGroupRecords }
*
*/
public MetaGroupRecords getGroupOfInnerRecords() {
return groupOfInnerRecords;
}
/**
* Sets the value of the groupOfInnerRecords property.
*
* @param value
* allowed object is {@link MetaGroupRecords }
*
*/
public void setGroupOfInnerRecords(MetaGroupRecords value) {
this.groupOfInnerRecords = value;
}
/**
* Gets the value of the description property.
*
* @return possible object is {@link String }
*
*/
public String getDescription() {
return description;
}
/**
* Sets the value of the description property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setDescription(String value) {
this.description = value;
}
/**
* Gets the value of the name property.
*
* @return possible object is {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Gets the value of the repeatable property.
*
* @return possible object is {@link Boolean }
*
*/
public boolean isRepeatable() {
if (repeatable == null) {
return false;
} else {
return repeatable;
}
}
/**
* Sets the value of the repeatable property.
*
* @param value
* allowed object is {@link Boolean }
*
*/
public void setRepeatable(Boolean value) {
this.repeatable = value;
}
}

View File

@ -0,0 +1,116 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>
* Elemento root.
* </p>
*
*
*
*
*
*/
@XmlRootElement(name = "Texgit")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MetaTexgit", propOrder = {
})
public class MetaTexgit {
@XmlElement(name = "FlatFile", required = true)
protected MetaFlatFile flatFile;
@XmlAttribute
protected String version;
/**
* Gets the value of the flatFile property.
*
* @return possible object is {@link MetaFlatFile }
*
*/
public MetaFlatFile getFlatFile() {
return flatFile;
}
/**
* Sets the value of the flatFile property.
*
* @param value
* allowed object is {@link MetaFlatFile }
*
*/
public void setFlatFile(MetaFlatFile value) {
this.flatFile = value;
}
/**
* Gets the value of the version property.
*
* @return possible object is {@link String }
*
*/
public String getVersion() {
if (version == null) {
return "1.0-academic";
} else {
return version;
}
}
/**
* Sets the value of the version property.
*
* @param value
* allowed object is {@link String }
*
*/
public void setVersion(String value) {
this.version = value;
}
}

View File

@ -0,0 +1,178 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
package org.jrimum.texgit.language;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each Java content interface and Java
* element interface generated in the texgit.language package.
* <p>
* An ObjectFactory allows you to programatically construct new instances of the
* Java representation for XML content. The Java representation of XML content
* can consist of schema derived interfaces and classes representing the binding
* of schema type definitions, element declarations and model groups. Factory
* methods for each of these are provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName TEXGIT_QNAME = new QName(
"http://jrimum.org/texgit", "Texgit");
/**
* Create a new ObjectFactory that can be used to create new instances of
* schema derived classes for package: texgit.language
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link MetaField }
*
*/
public MetaField createMetaField() {
return new MetaField();
}
/**
* Create an instance of {@link MetaFlatFile }
*
*/
public MetaFlatFile createMetaFlatFile() {
return new MetaFlatFile();
}
/**
* Create an instance of {@link MetaOrderedField }
*
*/
public MetaOrderedField createMetaOrderedField() {
return new MetaOrderedField();
}
/**
* Create an instance of {@link MetaRecord }
*
*/
public MetaRecord createMetaRecord() {
return new MetaRecord();
}
/**
* Create an instance of {@link MetaLayout }
*
*/
public MetaLayout createMetaLayout() {
return new MetaLayout();
}
/**
* Create an instance of {@link MetaTexgit }
*
*/
public MetaTexgit createMetaTexgit() {
return new MetaTexgit();
}
/**
* Create an instance of {@link MetaFormatter }
*
*/
public MetaFormatter createMetaFormatter() {
return new MetaFormatter();
}
/**
* Create an instance of {@link MetaGroupFields }
*
*/
public MetaGroupFields createMetaGroupFields() {
return new MetaGroupFields();
}
/**
* Create an instance of {@link MetaGroupRecords }
*
*/
public MetaGroupRecords createMetaGroupRecords() {
return new MetaGroupRecords();
}
/**
* Create an instance of {@link MetaFiller }
*
*/
public MetaFiller createMetaFiller() {
return new MetaFiller();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link MetaTexgit }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://jrimum.org/texgit", name = "Texgit")
public JAXBElement<MetaTexgit> createTexgit(MetaTexgit value) {
return new JAXBElement<MetaTexgit>(TEXGIT_QNAME, MetaTexgit.class,
null, value);
}
/**
* Create an instance of {@link MetaGroupFields.SequencialNumber }}
*
*/
@XmlElementDecl(namespace = "", name = "SequencialNumber", scope = MetaGroupFields.class)
public MetaGroupFields.SequencialNumber createMetaGroupFieldsSequencialNumber(
MetaOrderedField value) {
return new MetaGroupFields.SequencialNumber(value);
}
/**
* Create an instance of {@link MetaGroupFields.IdType }}
*
*/
@XmlElementDecl(namespace = "", name = "IdType", scope = MetaGroupFields.class)
public MetaGroupFields.IdType createMetaGroupFieldsIdType(
MetaOrderedField value) {
return new MetaGroupFields.IdType(value);
}
}

View File

@ -0,0 +1,40 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB)
// Reference Implementation, vJAXB 2.0 in JDK 1.6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source
// schema.
// Generated on: 2008.08.03 at 12:27:56 AM GMT-03:00
//
@javax.xml.bind.annotation.XmlSchema(namespace = "http://jrimum.org/texgit")
package org.jrimum.texgit.language;

View File

@ -0,0 +1,332 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type;
import static java.lang.String.format;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import org.apache.commons.lang.StringUtils;
import org.jrimum.texgit.TextStream;
import org.jrimum.utilix.Collections;
import org.jrimum.utilix.Objects;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @param <G>
*/
@SuppressWarnings("serial")
public abstract class AbstractStringOfFields<G extends Field<?>> implements TextStream, List<G>, Cloneable{
/**
*
*/
private ArrayList<G> fields;
/**
*
*/
public AbstractStringOfFields() {
fields = new ArrayList<G>();
}
/**
*
*/
public AbstractStringOfFields(Integer size) {
Objects.checkNotNull(size, "size");
if (size > 0) {
fields = new ArrayList<G>(size);
for (int i = 1; i <= size; i++){
fields.add(null);
}
} else {
throw new IllegalArgumentException(format("A quantidade de campos [%s] deve ser um número natural > 0!", size));
}
}
@SuppressWarnings("unchecked")
@Override
protected AbstractStringOfFields<G> clone() throws CloneNotSupportedException {
//Clona apenas com uma referência a fields.
AbstractStringOfFields<G> sof = (AbstractStringOfFields<G>) super.clone();
//Clonagem real
sof.fields = new ArrayList<G>();
for(G gf : fields)
sof.fields.add((G) gf.clone());
return sof;
}
/**
* <p>
* A leitrua de uma string, ou melhor, a divisão de uma string em fields,
* não ocorre sem uma lógica. Assim este método deve ser implementado por
* cada subclasse.
* </p>
*
* @see org.jrimum.texgit.ReadWriteStream#read(Object)
*/
public abstract void read(String lineOfField);
/**
* <p>
* Escreve os campos na ordem em que estão dispostos na lista em uma única linha (string).
* </p>
*
* @see org.jrimum.texgit.ReadWriteStream#write()
*/
public String write() {
StringBuilder lineOfFields = new StringBuilder(StringUtils.EMPTY);
Objects.checkNotNull(fields, "Fields == null");
Collections.checkNotEmpty(fields, "Coleção de fields vazia!");
for (G field : fields) {
try {
lineOfFields.append(field.write());
} catch (Exception e) {
throw new IllegalStateException(
format(
"Erro ao tentar escrever o campo \"%s\" com valor [%s] na posição [%s] no layout do registro.",
field.getName(), field.getValue(), fields
.indexOf(field)+1),e);
}
}
return lineOfFields.toString();
}
/**
* @return the fields
*/
public List<G> getFields() {
return fields;
}
/**
* @see java.util.List#add(java.lang.Object)
*/
public boolean add(G e) {
return fields.add(e);
}
/**
* @see java.util.List#add(int, java.lang.Object)
*/
public void add(int index, G element) {
fields.add(index, element);
}
/**
* @see java.util.List#addAll(java.util.Collection)
*/
public boolean addAll(Collection<? extends G> c) {
return fields.addAll(c);
}
/**
* @see java.util.List#addAll(int, java.util.Collection)
*/
public boolean addAll(int index, Collection<? extends G> c) {
return fields.addAll(index, c);
}
/**
* @see java.util.List#clear()
*/
public void clear() {
fields.clear();
}
/**
* @see java.util.List#contains(java.lang.Object)
*/
public boolean contains(Object o) {
return fields.contains(o);
}
/**
* @see java.util.List#containsAll(java.util.Collection)
*/
public boolean containsAll(Collection<?> c) {
return fields.containsAll(c);
}
/**
* @see java.util.List#get(int)
*/
public G get(int index) {
return fields.get(index);
}
/**
* @see java.util.List#indexOf(java.lang.Object)
*/
public int indexOf(Object o) {
return fields.indexOf(o);
}
/**
* @see java.util.List#isEmpty()
*/
public boolean isEmpty() {
return fields.isEmpty();
}
/**
* @see java.util.List#iterator()
*/
public Iterator<G> iterator() {
return fields.iterator();
}
/**
* @see java.util.List#lastIndexOf(java.lang.Object)
*/
public int lastIndexOf(Object o) {
return fields.indexOf(o);
}
/**
* @see java.util.List#listIterator()
*/
public ListIterator<G> listIterator() {
return fields.listIterator();
}
/**
* @see java.util.List#listIterator(int)
*/
public ListIterator<G> listIterator(int index) {
return fields.listIterator(index);
}
/**
* @see java.util.List#remove(int)
*/
public G remove(int index) {
return fields.remove(index);
}
/**
* @see java.util.List#remove(java.lang.Object)
*/
public boolean remove(Object o) {
return fields.remove(o);
}
/**
* @see java.util.List#removeAll(java.util.Collection)
*/
public boolean removeAll(Collection<?> c) {
return fields.removeAll(c);
}
/**
* @see java.util.List#retainAll(java.util.Collection)
*/
public boolean retainAll(Collection<?> c) {
return fields.retainAll(c);
}
/**
* @see java.util.List#set(int, java.lang.Object)
*/
public G set(int index, G element) {
return fields.set(index, element);
}
/**
* @see java.util.List#size()
*/
public int size() {
return fields.size();
}
/**
* @see java.util.List#subList(int, int)
*/
public List<G> subList(int fromIndex, int toIndex) {
return fields.subList(fromIndex, toIndex);
}
/**
* @see java.util.List#toArray()
*/
public Object[] toArray() {
return fields.toArray();
}
/**
* @see java.util.List#toArray(Object[])
*/
public <T> T[] toArray(T[] a) {
return fields.toArray(a);
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type;
import java.text.Format;
import org.jrimum.texgit.TextStream;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @param <G>
*/
public interface Field<G> extends TextStream, Cloneable{
public abstract String getName();
public abstract void setName(String name);
public abstract G getValue();
public abstract void setValue(G value);
public abstract Format getFormatter();
public abstract void setFormatter(Format formatter);
public abstract boolean isBlankAccepted();
public abstract void setBlankAccepted(boolean blankAccepted);
public abstract Field<G> clone() throws CloneNotSupportedException;
}

View File

@ -0,0 +1,162 @@
package org.jrimum.texgit.type;
import java.io.Serializable;
import org.jrimum.texgit.TextStream;
public interface Filler extends Serializable{
/**
* Preenche o campo com o caracter especificado e no lado especificado.
*
* <p>
* Exemplo:
* <br/>
* Se <code>sideToFill == SideToFill.LEFT</code>, o caracter especificado será adicionado à String
* no lado esquerdo até que o campo fique com o tamanho que foi definido.
* </p>
*
* @param toFill
* @param length
* @return String preenchida
*
* @since 0.2
*/
String fill(String toFill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>String.valueOf(toFill)</code>.
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(long tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>String.valueOf(toFill)</code>.
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(int tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>String.valueOf(toFill)</code>.
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(short tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>String.valueOf(toFill)</code>.
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(byte tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>String.valueOf(toFill)</code>.
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(char tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>String.valueOf(toFill)</code>.
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(double tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>String.valueOf(toFill)</code>.
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since
*/
String fill(float tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>toFill.toString()</code>.
*
* <p>
* Caso <code>toFill</code> seja <code>null</code>, o método
* <code>fill(String, int)</code> receberá uma String nula como parâmetro.
* </p>
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(Object tofill, int length);
/**
* Executa o método <code>fill(String, int)</code> passando o parâmetro
* <code>toFill</code> como <code>toFill.write()</code>.
*
* <p>
* Caso <code>toFill</code> seja <code>null</code>, o método
* <code>fill(String, int)</code> receberá uma String nula como parâmetro.
* </p>
*
* @param tofill
* @param length
* @return String preenchida
*
* @see Filler#fill(String, int)
*
* @since 0.2
*/
String fill(TextStream tofill, int length);
}

View File

@ -0,0 +1,52 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public interface Fixed {
/**
* Informa a validade para a fixação de uma ou mais medidas. Exemplo: <br />
*
* <pre>
* {
* isLenghtAsDefine();
* isSizeAsDefine();
* }
* </pre>
*
* @return Indicativo se está de acordo com o definido
*
* @throws IllegalStateException
*/
public abstract boolean isFixedAsDefined() throws IllegalStateException;
}

View File

@ -0,0 +1,48 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @param <G>
*/
public interface FixedField<G> extends Field<G>, FixedLength{
/**
* @return the filler
*/
public abstract Filler getFiller();
/**
* @param filler the filler to set
*/
public abstract void setFiller(Filler filler);
}

View File

@ -0,0 +1,42 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public interface FixedLength extends Fixed{
public Integer getFixedLength();
public boolean isTruncate();
public void setTruncate(boolean truncate);
}

View File

@ -0,0 +1,38 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public interface FixedSize extends Fixed{
public Integer getFixedSize();
}

View File

@ -0,0 +1,228 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type.component;
import static java.lang.String.format;
import static org.jrimum.utilix.Objects.isNotNull;
import org.jrimum.texgit.type.AbstractStringOfFields;
import org.jrimum.texgit.type.FixedLength;
import org.jrimum.texgit.type.FixedSize;
import org.jrimum.utilix.Collections;
import org.jrimum.utilix.Objects;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
@SuppressWarnings("serial")
public class BlockOfFields extends AbstractStringOfFields<FixedField<?>> implements FixedSize, FixedLength{
/**
* Definição
*/
private Integer length;
/**
* Definição
*/
private Integer size;
/**
* <p>
* Tamanho da string de escrita do bloco.
* </p>
*/
private Integer instantLength;
/**
* <p>
* Ao ultrapassar o tamanho, define se pode truncar ou se dispara uma exceção.
* </p>
*/
private boolean truncate;
/**
*
*/
public BlockOfFields() {
super();
}
/**
* @param length
* @param size
*/
public BlockOfFields(Integer length, Integer size) {
super(size);
Objects.checkNotNull(length, "length");
if (length > 0) {
setLength(length);
setSize(size);
} else
throw new IllegalArgumentException(format("O comprimento do bloco [%s] deve ser um número natural > 0!", length));
}
@Override
public BlockOfFields clone() throws CloneNotSupportedException {
return(BlockOfFields) super.clone();
}
@Override
public void read(String lineOfFields) {
Objects.checkNotNull(lineOfFields, "String de leitura nula!");
Objects.checkNotNull(getFields(), "Fields == null");
Collections.checkNotEmpty(getFields(), "Coleção de fields vazia!");
if (isSizeAsDefinaed() && isLengthWithDefinaed(lineOfFields.length())) {
StringBuilder builder = new StringBuilder(lineOfFields);
for (FixedField<?> field : getFields()) {
try {
field.read(builder.substring(0, field.getFixedLength()));
builder.delete(0, field.getFixedLength());
} catch (Exception e) {
throw new IllegalStateException(
format(
"Erro ao tentar ler o campo \"%s\" na posição [%s] no layout do registro.",
field.getName(), getFields().indexOf(field)+1),e);
}
}
builder = null;
}
}
@Override
public String write() {
Objects.checkNotNull(getFields(), "Fields == null");
Collections.checkNotEmpty(getFields(), "Coleção de fields vazia!");
String str = null;
isSizeAsDefinaed();
str = super.write();
instantLength = str.length();
if (isTruncate() && instantLength > getFixedLength()) {
str = str.substring(0, getFixedLength());
instantLength = getFixedLength();
}
isFixedAsDefined();
return str;
}
public boolean isFixedAsDefined() throws IllegalStateException {
return (isSizeAsDefinaed() && isLengthWithDefinaed());
}
private boolean isLengthWithDefinaed(){
return isLengthWithDefinaed(instantLength);
}
private boolean isLengthWithDefinaed(int length){
if(length == getFixedLength())
return true;
else
throw new IllegalStateException(format("O comprimento da string [%s] é incompátivel com o definido [%s] no layout do registro!",length,getFixedLength()));
}
private boolean isSizeAsDefinaed(){
if(size() == getFixedSize())
return true;
else
throw new IllegalStateException(format("O número de fields [%s] é incompátivel com o definido [%s]!", size(), getFixedSize()));
}
/**
* @return the length
*/
public Integer getFixedLength() {
return length;
}
/**
* @param length the length to set
*/
protected void setLength(Integer length) {
if (isNotNull(length))
this.length = length;
else
throw new IllegalArgumentException(format("Comprimento inválido [%s]!", length));
}
/**
* @return the size
*/
public Integer getFixedSize() {
return size;
}
/**
* @param size the size to set
*/
protected void setSize(Integer size) {
if (isNotNull(size))
this.size = size;
else
throw new IllegalArgumentException(format("Tamanho inválido [%s]!", size));
}
public boolean isTruncate() {
return this.truncate;
}
public void setTruncate(boolean truncate) {
this.truncate = truncate;
}
}

View File

@ -0,0 +1,406 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type.component;
import static java.lang.String.format;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNumeric;
import static org.jrimum.utilix.Objects.isNotNull;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.Format;
import java.text.ParseException;
import java.util.Date;
import org.jrimum.texgit.TextStream;
import org.jrimum.utilix.Dates;
import org.jrimum.utilix.Objects;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @param <G>
*/
@SuppressWarnings("serial")
public class Field<G> implements org.jrimum.texgit.type.Field<G>{
/**
*<p>
*Nome do campo, também pode ser usado como id.
* </p>
*/
private String name;
/**
* <p>
* Valor do campo.
* </p>
*/
private G value;
/**
* <p>
* Formatador utilizado na leitura e escrita do valor do campo.
* </p>
*/
private Format formatter;
/**
* <p>
* Necessário para ler campos númericos em branco.
* </p>
*/
private boolean blankAccepted;
/**
*
*/
public Field() {
super();
}
/**
* @param value
*/
public Field(G value) {
super();
setValue(value);
}
/**
* <p>
* Cria um <code>Field</code> com um valor e um formatador para o valor. Isto significa que a leitura e escrita do valor informado
* será de acordo com o formatador.
* </p>
*
* @param value
* @param formatter
*/
public Field(G value, Format formatter){
setValue(value);
setFormatter(formatter);
}
/**
* @param name
* @param value
*/
public Field(String name, G value) {
super();
setName(name);
setValue(value);
}
/**
* <p>
* Cria um <code>Field</code> com nome para identificação, valor e um formatador.
* </p>
*
* @param name
* @param value
* @param formatter
*
* @see #Field(Object, Format)
*/
public Field(String name, G value, Format formatter){
setName(name);
setValue(value);
setFormatter(formatter);
}
@SuppressWarnings("unchecked")
@Override
public Field<G> clone() throws CloneNotSupportedException {
return (Field<G>) super.clone();
}
public void read(String str) {
Objects.checkNotNull(str, "String inválida [null]!");
try{
if (this.value instanceof TextStream) {
TextStream reader = (TextStream) this.value;
reader.read(str);
} else if (this.value instanceof BigDecimal) {
readDecimalField(str);
} else if (this.value instanceof Date) {
readDateField(str);
} else if (this.value instanceof Character) {
readCharacter(str);
} else {
readStringOrNumericField(str);
}
}catch (Exception e) {
throw new IllegalStateException(format("Falha na leitura do campo! %s",toString()),e);
}
}
@SuppressWarnings("unchecked")
private void readCharacter(String str) {
if(str.length() == 1){
value = (G) new Character(str.charAt(0));
}else
throw new IllegalArgumentException("String com mais de 1 character!");
}
@SuppressWarnings("unchecked")
private void readDecimalField(String str) {
DecimalFormat decimalFormat = (DecimalFormat) formatter;
try {
String number = parseNumber(str);
Long parsedValue = (Long) formatter.parseObject(number);
BigDecimal decimalValue = new BigDecimal(parsedValue.longValue());
decimalValue = decimalValue.movePointLeft(decimalFormat.getMaximumFractionDigits());
value = (G) decimalValue;
}
catch (ParseException e) {
throwReadError(e, str);
}
}
@SuppressWarnings("unchecked")
private void readDateField(String str) {
try {
if(isBlank(str)){
if(isBlankAccepted()){
value = (G) Dates.invalidDate();
}else{
new IllegalArgumentException(format("Campo data vazio não permitido: [%s]!",str));
}
}else{
value = (G) formatter.parseObject(str);
}
} catch (ParseException e) {
throwReadError(e, str);
}
}
@SuppressWarnings("unchecked")
private void readStringOrNumericField(String str) {
str = parseNumber(str);
Class<?> clazz = value.getClass();
if(clazz.equals(String.class)){
value = (G) str;
}else{
readNumeric(clazz,str);
}
}
@SuppressWarnings("unchecked")
private void readNumeric(Class<?> clazz, String str) {
for (Constructor<?> cons : clazz.getConstructors()) {
if (cons.getParameterTypes().length == 1){
if (cons.getParameterTypes()[0].equals(String.class)){
try {
value = (G) cons.newInstance(str);
} catch (Exception e) {
throwReadError(e, str);
}
}
}
}
}
public String write() {
try{
String str = null;
if (value instanceof TextStream) {
TextStream its = (TextStream) value;
str = its.write();
} else if (value instanceof Date) {
str = writeDateField();
}
else if (value instanceof BigDecimal)
str = writeDecimalField();
else
str = value.toString();
return str;
}catch (Exception e) {
throw new IllegalStateException(format("Falha na escrita do campo escrita! %s",toString()),e);
}
}
private String writeDecimalField(){
BigDecimal decimalValue = (BigDecimal) value;
decimalValue = decimalValue.movePointRight(((DecimalFormat)formatter).getMaximumFractionDigits());
return decimalValue.toString();
}
private String writeDateField(){
if (!Dates.equalsInvalidDate((Date) value)){
return formatter.format(value);
}
return EMPTY;
}
private String parseNumber(String str){
if(isBlank(str)){
if(isBlankAccepted())
str = "0";
else
new IllegalArgumentException(format("Campo numérico vazio não permitido: [%s]!",str));
}else
if(!isNumeric(str))
new IllegalArgumentException(format("O campo deve ser numérico e não: [%s]!",str));
return str;
}
public String getName() {
return name;
}
public void setName(String name) {
if (isNotNull(name))
this.name = name;
else
throw new IllegalArgumentException(format("Nome Inválido: [%s]!",name));
}
public boolean isBlankAccepted() {
return this.blankAccepted;
}
public void setBlankAccepted(boolean blankAccepted) {
this.blankAccepted = blankAccepted;
}
public G getValue() {
return value;
}
public void setValue(G value) {
if (isNotNull(value))
this.value = value;
else
throw new IllegalArgumentException(format("Valor Inválido: %s = [%s]!", this.name, value));
}
public Format getFormatter() {
return formatter;
}
public void setFormatter(Format formatter) {
if (isNotNull(formatter))
this.formatter = formatter;
else
throw new IllegalArgumentException(format("Formato inválido: [%s]!",formatter));
}
private void throwReadError(Exception e, String value){
throw new IllegalArgumentException(format("Falha na leitura da string: [\"%s\"]! %s",value,toString()), e);
}
@Override
public String toString() {
return format("Field [name=\"%s\", value=\"%s\", isBlankAccepted=%s, formatter=%s]"
, Objects.whenNull(this.name, EMPTY)
, Objects.whenNull(this.value, EMPTY)
, Objects.whenNull(this.isBlankAccepted(), EMPTY)
, Objects.whenNull(this.formatter, EMPTY));
}
}

View File

@ -0,0 +1,264 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 30/03/2008 - 18:17:00
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 30/03/2008 - 18:17:00
*
*/
package org.jrimum.texgit.type.component;
import static java.lang.String.format;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.jrimum.utilix.Objects.isNotNull;
import org.apache.commons.lang.StringUtils;
import org.jrimum.texgit.TextStream;
import org.jrimum.utilix.Objects;
/**
* <p>
* Preenchedor de caracteres genérico. É utilizado para preencher objetos <code>String</code>,
* tanto da esquerda para a direita como da direita para esquerda, com o objeto genérico até
* o tamanho especificado. Caso o tamanho especificado seja <strong>menor</strong>
* ou <strong>igual</strong> a 0 (ZERO), este valor será desconsiderado e nada será preenchido.
* </p>
* <p>
* É utilizado o método <code>toString()</code> do objeto preenchedor.
* </p>
* <p>
* Exemplo:<br/>
* <pre>
* Filler<Integer> filler = new Filler(new Integer(10), SideToFill.LEFT);
* String outPut = filler.fill("TESTE", 8);
*
* outPut -> "101TESTE"
* </pre>
* </p>
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L</a>
* @author <a href="mailto:misaelbarreto@gmail.com">Misael Barreto</a>
* @author <a href="mailto:romulomail@gmail.com">Rômulo Augusto</a>
* @author <a href="http://www.nordestefomento.com.br">Nordeste Fomento
* Mercantil</a>
*
* @since JRimum 0.1
*
* @version 0.2.1-inc
*
*/
@SuppressWarnings("serial")
public class Filler<G> implements org.jrimum.texgit.type.Filler{
private G padding;
private Side sideToFill;
public Filler() {
super();
}
/**
* @param fillWith
*/
public Filler(G fillWith) {
setPadding(fillWith);
setSideToFill(Side.LEFT);
}
/**
* @param fillWith
* @param sideToFill
*/
public Filler(G fillWith, Side sideToFill) {
setPadding(fillWith);
setSideToFill(sideToFill);
}
/**
* @see org.jrimum.texgit.type#getPadding()
*/
public G getPadding() {
return padding;
}
/**
* @see org.jrimum.texgit.type#setPadding(G)
*/
public void setPadding(G fillWith) {
if(isNotNull(fillWith)){
this.padding = fillWith;
}else{
throw new IllegalArgumentException(format("Preenchimento inválido [%s]!",fillWith));
}
}
/**
* @see org.jrimum.texgit.type#getSideToFill()
*/
public Side getSideToFill() {
return sideToFill;
}
/**
* @see org.jrimum.texgit.type#setSideToFill(org.jrimum.texgit.type.component.Side)
*/
public void setSideToFill(Side sideToFill) {
if(isNotNull(sideToFill)){
this.sideToFill = sideToFill;
}else{
throw new IllegalArgumentException(format("Lado para preenchimento [%s]!",sideToFill));
}
}
/**
* @see org.jrimum.texgit.type#fill(java.lang.String, int)
*/
public String fill(String toFill, int length){
String str = null;
switch(sideToFill){
case LEFT:
str = fillLeft(toFill, length);
break;
case RIGHT:
str = fillRight(toFill, length);
break;
}
return str;
}
/**
* @see org.jrimum.texgit.type#fill(long, int)
*/
public String fill(long tofill, int length){
return fill(String.valueOf(tofill), length);
}
/**
* @see org.jrimum.texgit.type#fill(int, int)
*/
public String fill(int tofill, int length){
return fill(String.valueOf(tofill), length);
}
/**
* @see org.jrimum.texgit.type#fill(short, int)
*/
public String fill(short tofill, int length){
return fill(String.valueOf(tofill), length);
}
/**
* @see org.jrimum.texgit.type#fill(byte, int)
*/
public String fill(byte tofill, int length){
return fill(String.valueOf(tofill), length);
}
/**
* @see org.jrimum.texgit.type#fill(char, int)
*/
public String fill(char tofill, int length){
return fill(String.valueOf(tofill), length);
}
/**
* @see org.jrimum.texgit.type#fill(double, int)
*/
public String fill(double tofill, int length){
return fill(String.valueOf(tofill), length);
}
/**
* @see org.jrimum.texgit.type#fill(float, int)
*/
public String fill(float tofill, int length){
return fill(String.valueOf(tofill), length);
}
/**
* @see org.jrimum.texgit.type#fill(java.lang.Object, int)
*/
public String fill(Object tofill, int length){
String toFillTemp = null;
if(isNotNull(tofill)){
toFillTemp = tofill.toString();
}
return fill(toFillTemp, length);
}
/**
* @see org.jrimum.texgit.type#fill(org.jrimum.texgit.TextStream, int)
*/
public String fill(TextStream tofill, int length){
String toFillTemp = null;
if(isNotNull(tofill)){
toFillTemp = tofill.write();
}
return fill(toFillTemp, length);
}
/**
* @param toFill
* @param length
* @return String preenchida
*/
private String fillRight(String toFill, int length) {
return StringUtils.rightPad(toFill, length, padding.toString());
}
/**
* @param toFill
* @param length
* @return String preenchida
*/
private String fillLeft(String toFill, int length) {
return StringUtils.leftPad(toFill, length, padding.toString());
}
@Override
public String toString() {
return format(
"Filler [padding=\"%s\", sideToFill=%s]"
, Objects.whenNull(this.padding, EMPTY)
, Objects.whenNull(this.sideToFill, EMPTY));
}
}

View File

@ -0,0 +1,167 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type.component;
import org.jrimum.texgit.TextStream;
import org.jrimum.utilix.text.Strings;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
public enum Fillers implements org.jrimum.texgit.type.Filler{
/**
* Filler padrão para preenchimento com zeros a esquerda.
*/
ZERO_LEFT(new Filler<Integer>(0, Side.LEFT)),
/**
* Filler padrão para preenchimento com zeros a direita.
*/
ZERO_RIGHT(new Filler<Integer>(0, Side.RIGHT)),
/**
* Filler padrão para preenchimento com espaços em branco a esquerda.
*/
WHITE_SPACE_LEFT(new Filler<String>(Strings.WHITE_SPACE, Side.LEFT)),
/**
* Filler padrão para preenchimento com espaços em branco a direita.
*/
WHITE_SPACE_RIGHT(new Filler<String>(Strings.WHITE_SPACE, Side.RIGHT));
private Filler<?> filler;
private Fillers(Filler<?> filler){
this.filler = filler;
}
/**
* @param toFill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(java.lang.String, int)
*/
public String fill(String toFill, int length) {
return filler.fill(toFill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(long, int)
*/
public String fill(long tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(int, int)
*/
public String fill(int tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(short, int)
*/
public String fill(short tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(byte, int)
*/
public String fill(byte tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(char, int)
*/
public String fill(char tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(double, int)
*/
public String fill(double tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(float, int)
*/
public String fill(float tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(java.lang.Object, int)
*/
public String fill(Object tofill, int length) {
return filler.fill(tofill, length);
}
/**
* @param tofill
* @param length
* @return String preenchida
* @see org.jrimum.texgit.type.component.Filler#fill(org.jrimum.texgit.TextStream, int)
*/
public String fill(TextStream tofill, int length) {
return filler.fill(tofill, length);
}
}

View File

@ -0,0 +1,233 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type.component;
import static java.lang.String.format;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.jrimum.utilix.Objects.isNotNull;
import java.text.Format;
import org.jrimum.texgit.type.Filler;
import org.jrimum.utilix.Objects;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @param <G>
*/
@SuppressWarnings("serial")
public class FixedField<G> extends Field<G> implements org.jrimum.texgit.type.FixedField<G>{
/**
* <p>
* Tamanho de especificação e parâmetro da string de leitura ou escrita do campo.
* </p>
*/
private Integer length;
/**
* <p>
* Preenchedor do valor utilizado na hora da escrita.
* </p>
*/
private Filler filler;
/**
* <p>
* Tamanho da string de escrita do campo.
* </p>
*/
private Integer instantLength;
/**
* <p>
* Ao ultrapassar o tamanho, define se pode truncar ou se dispara uma exceção.
* </p>
*/
private boolean truncate;
/**
*
*/
public FixedField() {
super();
}
public FixedField(G value, Integer length) {
super(value);
setFixedLength(length);
}
public FixedField(G value, Integer length, Filler filler) {
super(value);
setFixedLength(length);
setFiller(filler);
}
public FixedField(G value, Integer length, Format formatter) {
super(value,formatter);
setFixedLength(length);
}
public FixedField(G value, Integer length, Format formatter, Filler filler) {
super(value,formatter);
setFixedLength(length);
setFiller(filler);
}
public FixedField(String name, G value, Integer length) {
super(name,value);
setFixedLength(length);
}
public FixedField(String name, G value, Integer length, Filler filler) {
super(name,value);
setFixedLength(length);
setFiller(filler);
}
public FixedField(String name, G value, Integer length, Format formatter) {
super(name,value,formatter);
setFixedLength(length);
}
public FixedField(String name, G value, Integer length, Format formatter, Filler filler) {
super(name,value,formatter);
setFixedLength(length);
setFiller(filler);
}
@Override
public FixedField<G> clone() throws CloneNotSupportedException {
return (FixedField<G>) super.clone();
}
/**
* @see org.jrimum.texgit.type.component.Field#read(java.lang.String)
*/
@Override
public void read(String str) {
Objects.checkNotNull(str, "String inválida [null]!");
if (str.length() == getFixedLength()) {
super.read(str);
} else
throw new IllegalArgumentException(format("Tamanho da string [%s] diferente do especificado [%s]! %s",str.length(),getFixedLength(),toString()));
}
/**
* @see org.jrimum.texgit.type.component.Field#write()
*/
@Override
public String write() {
String str = fill(super.write());
instantLength = str.length();
if (isTruncate() && instantLength > getFixedLength()) {
str = str.substring(0, getFixedLength());
instantLength = getFixedLength();
}
isFixedAsDefined();
return str;
}
private String fill(String str) {
if(isNotNull(filler))
str = filler.fill(str, length);
return str;
}
public boolean isFixedAsDefined() throws IllegalStateException {
if(instantLength.equals(getFixedLength()))
return true;
else
throw new IllegalStateException(format("Tamanho da string [%s] diferente do especificado [%s]! %s",instantLength,getFixedLength(),toString()));
}
public Integer getFixedLength() {
return this.length;
}
public void setFixedLength(Integer length) {
if (isNotNull(length) && length.intValue() > 0)
this.length = length;
else
throw new IllegalArgumentException(format("Comprimento inválido [%s]!",length));
}
public Filler getFiller() {
return filler;
}
public void setFiller(Filler filler) {
if(isNotNull(filler))
this.filler = filler;
else
throw new IllegalArgumentException(format("Preenchedor inválido [%s]!",filler));
}
public boolean isTruncate() {
return this.truncate;
}
public void setTruncate(boolean truncate) {
this.truncate = truncate;
}
@Override
public String toString() {
return format(
"%s FixedField [length=%s, instantLength=%s, filler=%s, truncate=%s]",
super.toString()
, Objects.whenNull(this.length, EMPTY)
, Objects.whenNull(this.instantLength, EMPTY)
, Objects.whenNull(this.filler, EMPTY)
, Objects.whenNull(this.truncate, EMPTY));
}
}

View File

@ -0,0 +1,321 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type.component;
import static java.lang.String.format;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.jrimum.utilix.Objects.isNotNull;
import static org.jrimum.utilix.Objects.isNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
@SuppressWarnings("serial")
public class FlatFile implements org.jrimum.texgit.FlatFile<org.jrimum.texgit.Record>{
private List<Record> records;
private Set<String> repitablesRecords;
private List<String> recordsOrder;
private RecordFactory<Record> recordFactory;
public FlatFile(RecordFactory<Record> iFac4Rec) {
this.recordFactory = iFac4Rec;
this.records = new ArrayList<Record>();
}
public Record getRecord(String idName){
Record record = null;
if (isNotBlank(idName)) {
if (!isRepitable(idName)){
if (!records.isEmpty()) {
for (Record rec : records) {
if (idName.equals(rec.getName()))
record = rec;
}
}
}
}
return record;
}
public boolean isRepitable(String idName){
return (isNotNull(repitablesRecords) && !repitablesRecords.isEmpty() && repitablesRecords.contains(idName));
}
public org.jrimum.texgit.Record createRecord(String idName){
return recordFactory.create(idName);
}
public void addRecord(Record record){
if(isNotNull(record))
if(isMyRecord(record.getName()))
records.add(record);
else
throw new IllegalArgumentException("Record fora de scopo!");
}
public boolean isMyRecord(String idName){
boolean is = false;
if (isNotBlank(idName)) {
if(!recordsOrder.isEmpty())
if(recordsOrder.contains(idName))
is = true;
}
return is;
}
public void read(List<String> str) {
if(isNotNull(str)){
if(!str.isEmpty()){
String line = null;
int lineIndex = 0;
FixedField<String> typeRecord = null;
Record record = null;
for(String id : recordsOrder){
record = recordFactory.create(id);
try{
if(isRepitable(id)){
boolean read = true;
while(read){
if(isNull(record))
record = recordFactory.create(id);
if(lineIndex < str.size())
line = str.get(lineIndex);
typeRecord = record.readID(line);
read = record.getIdType().getValue().equals(typeRecord.getValue()) && (lineIndex < str.size());
if(read){
record.read(line);
lineIndex++;
addRecord(record);
if(record.isHeadOfGroup()){
lineIndex = record.readInnerRecords(str,lineIndex,recordFactory);
}
record = null;
}
}
}else{
if((lineIndex < str.size())){
line = str.get(lineIndex);
typeRecord = record.readID(line);
if(record.getIdType().getValue().equals(typeRecord.getValue())){
record.read(line);
lineIndex++;
addRecord(record);
if(record.isHeadOfGroup()){
lineIndex = record.readInnerRecords(str,lineIndex,recordFactory);
}
record = null;
}
}
}
} catch (Exception e) {
throw new IllegalStateException(format(
"Erro ao tentar ler o registro \"%s\".", record.getName()), e);
}
}
}
}
}
public List<String> write() {
return write(EMPTY);
}
public List<String> write(String lineEnding) {
ArrayList<String> out = new ArrayList<String>(records.size());
for(String id : recordsOrder){
if(isRepitable(id)){
Record rec = null;
for(org.jrimum.texgit.Record record : getRecords(id)){
rec = Record.class.cast(record);
try{
out.add(rec.write()+lineEnding);
} catch (Exception e) {
throw new IllegalStateException(format(
"Erro ao tentar escrever o registro \"%s\".", rec.getName()), e);
}
if(rec.isHeadOfGroup() && rec.hasInnerRecords()){
out.addAll(rec.writeInnerRecords(lineEnding));
}
}
}else{
Record rec = getRecord(id);
try{
out.add(rec.write()+lineEnding);
} catch (Exception e) {
throw new IllegalStateException(format(
"Erro ao tentar escrever o registro \"%s\".", rec.getName()), e);
}
if(rec.isHeadOfGroup() && rec.hasInnerRecords()){
out.addAll(rec.writeInnerRecords(lineEnding));
}
}
}
return out;
}
public org.jrimum.texgit.FlatFile<org.jrimum.texgit.Record> addRecord(org.jrimum.texgit.Record record) {
if(isNotNull(record)){
Record rec = Record.class.cast(record);
addRecord(rec);
}
return this;
}
public Collection<org.jrimum.texgit.Record> getRecords(String idName) {
List<org.jrimum.texgit.Record> secRecords = new ArrayList<org.jrimum.texgit.Record>();
if (isNotBlank(idName)) {
if (isRepitable(idName)) {
if (!records.isEmpty()) {
for (Record rec : records) {
if (idName.equals(rec.getName()))
secRecords.add(rec);
}
}
}
}
return secRecords;
}
public org.jrimum.texgit.FlatFile<org.jrimum.texgit.Record> addAllRecords(Collection<org.jrimum.texgit.Record> records) {
// TODO IMPLEMENTAR
throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
}
public org.jrimum.texgit.FlatFile<org.jrimum.texgit.Record> addRecords(String idName, Collection<org.jrimum.texgit.Record> records) {
// TODO IMPLEMENTAR
throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
}
public Collection<org.jrimum.texgit.Record> getAllRecords() {
// TODO IMPLEMENTAR
throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
}
public org.jrimum.texgit.Record removeRecord(String idName) {
// TODO IMPLEMENTAR
throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
}
public org.jrimum.texgit.FlatFile<org.jrimum.texgit.Record> setAllRecords(Collection<org.jrimum.texgit.Record> records) {
// TODO IMPLEMENTAR
throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
}
public org.jrimum.texgit.FlatFile<org.jrimum.texgit.Record> setRecords(String idName, Collection<org.jrimum.texgit.Record> records) {
// TODO IMPLEMENTAR
throw new UnsupportedOperationException("AINDA NÃO IMPLEMENTADO!");
}
public Set<String> getRepitablesRecords() {
return repitablesRecords;
}
public void setRepitablesRecords(Set<String> repitablesRecords) {
this.repitablesRecords = repitablesRecords;
}
public List<String> getRecordsOrder() {
return recordsOrder;
}
public void setRecordsOrder(List<String> recordsOrder) {
this.recordsOrder = recordsOrder;
}
}

View File

@ -0,0 +1,446 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type.component;
import static java.lang.String.format;
import static org.apache.commons.lang.StringUtils.EMPTY;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.jrimum.utilix.Objects.isNotNull;
import static org.jrimum.utilix.Objects.isNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.jrimum.texgit.type.Field;
import org.jrimum.utilix.Objects;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
*/
@SuppressWarnings("serial")
public class Record extends BlockOfFields implements org.jrimum.texgit.Record{
private String name;
private String description;
private FixedField<String> idType;
private FixedField<Long> sequencialNumber;
private boolean headOfGroup;
private List<org.jrimum.texgit.Record> innerRecords;
private Set<String> repitablesRecords;
private List<String> declaredInnerRecords;
public Record() {
super();
}
/**
* @param length
* @param size
*/
public Record(Integer length, Integer size) {
super(length, size);
}
@Override
public Record clone() throws CloneNotSupportedException {
//TODO Outros atributos
return (Record) super.clone();
}
@SuppressWarnings("null")
public FixedField<String> readID(String lineRecord) {
FixedField<String> ffID = null;
try {
ffID = getIdType().clone();
ffID.setName("");
} catch (CloneNotSupportedException e) {
throw new UnsupportedOperationException(format("Quebra de contrato [%s] não suporta clonagem!",Objects.whenNull(ffID, "FixedField", ffID.getClass())), e);
}
getIdType().read(lineRecord.substring(getIdPosition(), getIdPosition() + getIdType().getFixedLength()));
return ffID;
}
public org.jrimum.texgit.type.FixedField<?> getField(String fieldName) {
org.jrimum.texgit.type.FixedField<?> field = null;
if (isNotBlank(fieldName))
if (!getFields().isEmpty())
for (FixedField<?> ff : this.getFields())
if (ff.getName().equals(fieldName)) {
field = ff;
break;
}
return field;
}
public boolean isMyField(String idName){
boolean is = false;
if (isNotBlank(idName)) {
if(!getFields().isEmpty())
for(org.jrimum.texgit.type.Field<?> f : getFields())
if(idName.equals(f.getName())){
is = true;
break;
}
}
return is;
}
private int getIdPosition(){
int pos = 0;
for(FixedField<?> ff : this.getFields())
if(!ff.getName().equals(idType.getName()))
pos += ff.getFixedLength();
else
break;
return pos;
}
public int readInnerRecords(List<String> lines, int lineIndex, RecordFactory<Record> iFactory) {
return readInnerRecords(this,lines,lineIndex,iFactory);
}
private int readInnerRecords(Record record, List<String> lines, int lineIndex, RecordFactory<Record> iFactory) {
if(isNotNull(record)){
if(isNotNull(record.getDeclaredInnerRecords()) && !record.getDeclaredInnerRecords().isEmpty()){
boolean read = true;
String line = null;
FixedField<String> typeRecord = null;
Record innerRec = null;
for(String id : record.getDeclaredInnerRecords()){
innerRec = iFactory.create(id);
try{
if(isRepitable(id)){
while(read){
if(isNull(innerRec))
innerRec = iFactory.create(id);
if(lineIndex < lines.size())
line = lines.get(lineIndex);
typeRecord = innerRec.readID(line);
read = innerRec.getIdType().getValue().equals(typeRecord.getValue()) && (lineIndex < lines.size());
if(read){
innerRec.read(line);
lineIndex++;
record.addInnerRecord(innerRec);
if(innerRec.isHeadOfGroup())
innerRec.readInnerRecords(lines,lineIndex,iFactory);
innerRec = null;
}
}
}else{
if((lineIndex < lines.size())){
line = lines.get(lineIndex);
typeRecord = innerRec.readID(line);
if(innerRec.getIdType().getValue().equals(typeRecord.getValue())){
innerRec.read(line);
lineIndex++;
record.addInnerRecord(innerRec);
if(innerRec.isHeadOfGroup())
innerRec.readInnerRecords(lines,lineIndex,iFactory);
innerRec = null;
}
}
}
} catch (Exception e) {
throw new IllegalStateException(format(
"Erro ao tentar ler o registro \"%s\".",
innerRec.getName()), e);
}
}
}
}
return lineIndex;
}
public List<String> writeInnerRecords(){
return writeInnerRecords(this,EMPTY);
}
public List<String> writeInnerRecords(String lineEnding){
return writeInnerRecords(this,lineEnding);
}
private List<String> writeInnerRecords(Record record, String lineEnding){
ArrayList<String> out = new ArrayList<String>(record.getInnerRecords().size());
for(String id : getDeclaredInnerRecords()){//ordem
if(isRepitable(id)){
for(Record rec : getRecords(id)){
try{
out.add(rec.write()+lineEnding);
} catch (Exception e) {
throw new IllegalStateException(format(
"Erro ao tentar escrever o registro \"%s\".", rec.getName()), e);
}
if(rec.isHeadOfGroup())
out.addAll(rec.writeInnerRecords());
}
}else{
Record rec = getRecord(id);
try{
out.add(rec.write()+lineEnding);
} catch (Exception e) {
throw new IllegalStateException(format(
"Erro ao tentar escrever o registro \"%s\".", rec.getName()), e);
}
if(rec.isHeadOfGroup())
out.addAll(rec.writeInnerRecords());
}
}
return out;
}
public Record getRecord(String idName){
Record record = null;
if (isNotBlank(idName)) {
if (!isRepitable(idName)){
if (!getInnerRecords().isEmpty()) {
for (org.jrimum.texgit.Record iRec : getInnerRecords()) {
Record rec = (Record) iRec;
if (idName.equals(rec.getName()))
record = rec;
}
}
}
}
return record;
}
public List<Record> getRecords(String idName) {
List<Record> secRecords = new ArrayList<Record>();
if (isNotBlank(idName)) {
if (isRepitable(idName)) {
if (!getInnerRecords().isEmpty()) {
for (org.jrimum.texgit.Record iRec : getInnerRecords()) {
Record rec = (Record) iRec;
if (idName.equals(rec.getName()))
secRecords.add(rec);
}
}
}
}
return secRecords;
}
public boolean isRepitable(String idName){
return (isNotNull(repitablesRecords) && !repitablesRecords.isEmpty() && repitablesRecords.contains(idName));
}
public boolean isMyRecord(String idName){
boolean is = false;
if (isNotBlank(idName)) {
if(!getDeclaredInnerRecords().isEmpty())
if(getDeclaredInnerRecords().contains(idName))
is = true;
}
return is;
}
public org.jrimum.texgit.Record addInnerRecord(org.jrimum.texgit.Record record) {
if(isNotNull(record)){
if(isNull(this.innerRecords))
this.innerRecords = new ArrayList<org.jrimum.texgit.Record>();
if(isMyRecord(Record.class.cast(record).getName()))
this.innerRecords.add(record);
else
throw new IllegalArgumentException("Record fora de scopo!");
}
return this;
}
public List<org.jrimum.texgit.Record> getInnerRecords() {
return this.innerRecords;
}
@SuppressWarnings("unchecked")
public <G> G getValue(String fieldName) {
G value = null;
org.jrimum.texgit.type.Field<?> f = getField(fieldName);
if(isNotNull(f))
value = (G) f.getValue();
return value;
}
@SuppressWarnings("unchecked")
public <G> org.jrimum.texgit.Record setValue(String fieldName, G value) {
org.jrimum.texgit.type.Field<G> f = (Field<G>) getField(fieldName);
if(isNotNull(f))
f.setValue(value);
return this;
}
public boolean hasInnerRecords(){
return getInnerRecords() != null && !getInnerRecords().isEmpty();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public FixedField<String> getIdType() {
return idType;
}
public void setIdType(FixedField<String> idType) {
this.idType = idType;
}
public FixedField<Long> getSequencialNumber() {
return sequencialNumber;
}
public void setSequencialNumber(FixedField<Long> sequencialNumber) {
this.sequencialNumber = sequencialNumber;
}
public boolean isHeadOfGroup() {
return headOfGroup;
}
public void setHeadOfGroup(boolean headOfGroup) {
this.headOfGroup = headOfGroup;
}
public List<String> getDeclaredInnerRecords() {
return declaredInnerRecords;
}
public void setDeclaredInnerRecords(List<String> declaredInnerRecords) {
this.declaredInnerRecords = declaredInnerRecords;
}
public Set<String> getRepitablesRecords() {
return repitablesRecords;
}
public void setRepitablesRecords(Set<String> repitablesRecords) {
this.repitablesRecords = repitablesRecords;
}
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 26/07/2008 - 12:44:41
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 26/07/2008 - 12:44:41
*
*/
package org.jrimum.texgit.type.component;
import org.jrimum.texgit.Record;
/**
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @param <G>
*/
public interface RecordFactory <G extends Record>{
public abstract G create(String name);
}

View File

@ -0,0 +1,13 @@
package org.jrimum.texgit.type.component;
/**
* Lados para alinhar campos, preenchimento ou orientações em geral.
*
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*/
public enum Side {
LEFT,
RIGHT;
}

View File

@ -0,0 +1,537 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 03/08/2008 - 12:27:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará “COMO ESTÁ”, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 03/08/2008 - 12:27:56
*
*/
-->
<!-- @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a> -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
elementFormDefault="unqualified" attributeFormDefault="unqualified"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0"
xmlns:txg="http://jrimum.org/texgit"
targetNamespace="http://jrimum.org/texgit">
<xs:annotation>
<xs:documentation>
Representação de classes e atributos usados para definição
da linguagem Texgit.
</xs:documentation>
</xs:annotation>
<xs:element name="Texgit" type="txg:MetaTexgit" />
<!-- ============== Tipos Complexos ============== -->
<xs:complexType name="MetaTexgit">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Elemento root.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:all>
<xs:element name="FlatFile" type="txg:MetaFlatFile"
minOccurs="1" maxOccurs="1" />
</xs:all>
<xs:attribute name="version" type="txg:TexgitVersion"
use="optional" default="1.0-academic">
<xs:annotation>
<xs:documentation>
Versão Da Linguagem Textgit
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="MetaFlatFile">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Flat File é um tipo de arquivo texto com informações estruturadas
com base em formatações e estruturas pré definidas. veja mais em (link).
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="layout" type="txg:MetaLayout"
minOccurs="0" maxOccurs="1" />
<xs:element name="GroupOfRecords"
type="txg:MetaGroupRecords" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="MetaLayout">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Tags para informar o layout do flafile definido.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:all>
<xs:element name="name" type="txg:MetaDescription"
minOccurs="0" maxOccurs="1" />
<xs:element name="version" type="txg:MetaDescription"
minOccurs="0" maxOccurs="1" />
<xs:element name="description" type="txg:MetaDescription"
minOccurs="0" maxOccurs="1" />
</xs:all>
</xs:complexType>
<xs:complexType name="MetaGroupRecords">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Conjunto de records de um flatfile ou relacionados a um outro record.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="Record" type="txg:MetaRecord"
minOccurs="1" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jxb:property name="records" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MetaRecord">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Uma espécie de container de fields numa forma mais simples, usualmente é conhecido como
Registro ou Bloco.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="GroupOfFields" type="txg:MetaGroupFields"
minOccurs="1" maxOccurs="1" />
<xs:element name="GroupOfInnerRecords"
type="txg:MetaGroupRecords" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="name" type="txg:MetaName" use="optional" />
<xs:attribute name="repeatable" type="xs:boolean" use="optional"
default="false" />
<xs:attribute name="description" type="txg:MetaDescription"
use="optional" />
</xs:complexType>
<xs:complexType name="MetaGroupFields">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Agregado de fields.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:sequence>
<xs:element name="IdType" type="txg:MetaOrderedField"
minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Identificação para um tipo de Record.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Field" type="txg:MetaField" minOccurs="1"
maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jxb:property name="fields" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="SequencialNumber"
type="txg:MetaOrderedField" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Field para sequenciamento do de um Record.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="MetaField">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Field é a unidade básica de informação de um registro, um field está para
um registro assim como uma coluna de banco de dados está para uma tabela.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:all>
<xs:element name="Filler" type="txg:MetaFiller"
minOccurs="0" maxOccurs="1" />
<xs:element name="Formatter" type="txg:MetaFormatter"
minOccurs="0" maxOccurs="1" />
</xs:all>
<xs:attribute name="name" type="txg:MetaName" use="required" />
<xs:attribute name="value" type="txg:MetaFormat" use="optional"
default=" " />
<xs:attribute name="length" type="txg:MetaLength"
use="required" />
<xs:attribute name="truncate" type="xs:boolean"
use="optional" default="false" />
<xs:attribute name="blankAccepted" type="xs:boolean"
use="optional" default="false" />
<xs:attribute name="type" type="txg:enumTypes" default="STRING" />
<xs:attribute name="format" type="txg:enumFormats"
use="optional" />
<xs:attribute name="padding" type="txg:enumPaddings"
use="optional" default="WHITE_SPACE_RIGHT" />
</xs:complexType>
<xs:complexType name="MetaOrderedField">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Para definição da posição.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:complexContent>
<xs:extension base="txg:MetaField">
<xs:attribute name="position" type="txg:MetaLength"
use="required" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MetaFiller">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Instrumento utilizado para preencher um field com um formato e caracteres
pré definidos.
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:sequence />
<xs:attribute name="padding" type="txg:MetaFormat"
use="required" />
<xs:attribute name="sideToFill" type="txg:enumSide"
use="optional" default="LEFT" />
</xs:complexType>
<xs:complexType name="MetaFormatter">
<xs:annotation>
<xs:appinfo>
<jxb:class>
<jxb:javadoc>
<![CDATA[
<p>
Formato utilizado por um Filler (Preenchedor).
</p>
]]>
</jxb:javadoc>
</jxb:class>
</xs:appinfo>
</xs:annotation>
<xs:sequence />
<xs:attribute name="format" type="txg:MetaFormat"
use="required" />
<xs:attribute name="type" type="txg:enumFormatsTypes"
use="required" />
</xs:complexType>
<!-- ============== Tipos Simples Atributos e Enumerações ============== -->
<!-- ============== Tipos Simples: Regras Para Atributos ============== -->
<xs:simpleType name="TexgitVersion">
<xs:annotation>
<xs:documentation>
Versão da linguagem utilizada para descricação de flat
files.
Padrão: "d.d ou d.d-'tag' ou d.d-'tag'd" Exemplo: 1.4 ou
1.23-beta ou 1.23-beta5
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse" />
<xs:minLength value="3" />
<xs:pattern value="(\d+\.\d+|\d+\.\d+\-[a-z]+\d*)" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="MetaName">
<xs:annotation>
<xs:documentation>
Tipificação e regras para campos strings utilizados como
identificadores. Padarão: letras,dígitos, traços (-) ou
underlines (_).
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="collapse" />
<xs:minLength value="1" />
<xs:pattern value="([a-zA-Z_\d\-])+" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="MetaDescription">
<xs:annotation>
<xs:documentation>
Tipificação e regras para descrição de campos strings.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="MetaLength">
<xs:annotation>
<xs:documentation>
Tipificação e regras para campos interios usados como
represenações de quantidade
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:int">
<xs:minInclusive value="1" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="MetaFormat">
<xs:annotation>
<xs:documentation>
Tipificação e regras para campos strings utilizados como
definições de formatos.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:minLength value="1" />
<xs:whiteSpace value="preserve" />
</xs:restriction>
</xs:simpleType>
<!-- ============== Tipos Simples: Enumerações Para Atributos ============== -->
<xs:simpleType name="enumFormats">
<xs:annotation>
<xs:appinfo>
<jxb:typesafeEnumClass>
<jxb:javadoc>
<![CDATA[
<p>
Formatos pré definidos suportados pelo
componente.
</p>
]]>
</jxb:javadoc>
</jxb:typesafeEnumClass>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="DATE_DDMMYY" />
<xs:enumeration value="DATE_DDMMYYYY" />
<xs:enumeration value="DATE_YYMMDD" />
<xs:enumeration value="DATE_YYYYMMDD" />
<xs:enumeration value="DECIMAL_D" />
<xs:enumeration value="DECIMAL_DD" />
<xs:enumeration value="DECIMAL_DDD" />
<xs:enumeration value="DECIMAL_DDDD" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="enumFormatsTypes">
<xs:annotation>
<xs:appinfo>
<jxb:typesafeEnumClass>
<jxb:javadoc>
<![CDATA[
<p>
Tipo de formatadores suportados. Usados junto a
definição de novos formatadores.
</p>
]]>
</jxb:javadoc>
</jxb:typesafeEnumClass>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="DATE" />
<xs:enumeration value="DECIMAL" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="enumPaddings">
<xs:annotation>
<xs:appinfo>
<jxb:typesafeEnumClass>
<jxb:javadoc>
<![CDATA[
<p>
Preenchimentos suportados por padrão pelo
componente.
</p>
]]>
</jxb:javadoc>
</jxb:typesafeEnumClass>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="ZERO_RIGHT" />
<xs:enumeration value="ZERO_LEFT" />
<xs:enumeration value="WHITE_SPACE_RIGHT" />
<xs:enumeration value="WHITE_SPACE_LEFT" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="enumSide">
<xs:annotation>
<xs:appinfo>
<jxb:typesafeEnumClass>
<jxb:javadoc>
<![CDATA[
<p>
Basicamente são definições de direções de
escrita e leitura.
</p>
]]>
</jxb:javadoc>
</jxb:typesafeEnumClass>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="LEFT" />
<xs:enumeration value="RIGHT" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="enumTypes">
<xs:annotation>
<xs:appinfo>
<jxb:typesafeEnumClass>
<jxb:javadoc>
<![CDATA[
<p>
Tipos usados para obtenção dos campos de texto
para java. No caso representa os tipos java
possíveis para um campo.
</p>
]]>
</jxb:javadoc>
</jxb:typesafeEnumClass>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="CHARACTER" />
<xs:enumeration value="STRING" />
<xs:enumeration value="INTEGER" />
<xs:enumeration value="LONG" />
<xs:enumeration value="FLOAT" />
<xs:enumeration value="DOUBLE" />
<xs:enumeration value="BIGDECIMAL" />
<xs:enumeration value="DATE" />
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -0,0 +1,257 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 30/03/2008 - 18:15:42
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 30/03/2008 - 18:15:42
*
*/
package org.jrimum.texgit.type.component;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.jrimum.texgit.TextStream;
import org.jrimum.texgit.type.component.Filler;
import org.jrimum.utilix.text.Strings;
import org.junit.Before;
import org.junit.Test;
/**
* <p>
* Teste unitário para a classe <code>Filler</code>.
* </p>
*
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
* @author <a href="mailto:romulomail@gmail.com">Rômulo Augusto</a>
*
* @since 0.2
*
* @version 0.2
*/
public class TestFiller {
private static final String CAMPO = "TESTE";
private static final int TAMANHO = 10;
private Filler<String> fillerString;
private Filler<Integer> fillerInteger;
private Filler<Double> fillerDouble;
private Filler<Side> fillerSide;
private Filler<String> whiteSpaceLeft;
private Filler<Integer> zeroLeft ;
private Filler<Integer> zeroRight;
@Before
public void setup(){
whiteSpaceLeft = new Filler<String>(Strings.WHITE_SPACE, Side.LEFT);
zeroLeft = new Filler<Integer>(0, Side.LEFT);
zeroRight = new Filler<Integer>(0, Side.RIGHT);
}
@Test(expected = IllegalArgumentException.class)
public void testSetSideNullValue() {
whiteSpaceLeft.setSideToFill(null);
}
@Test(expected = IllegalArgumentException.class)
public void testSetToFillNullValue() {
whiteSpaceLeft.setPadding(null);
}
@Test
public void testSetToFill() {
whiteSpaceLeft.setPadding(CAMPO);
assertTrue(whiteSpaceLeft.getPadding() instanceof String);
assertEquals(whiteSpaceLeft.getPadding(), CAMPO);
}
@Test
public void testSetSide() {
whiteSpaceLeft.setSideToFill(Side.RIGHT);
assertEquals(whiteSpaceLeft.getSideToFill(), Side.RIGHT);
}
@Test(expected = IllegalArgumentException.class)
public void testFiller() {
new Filler<String>(null, null);
new Filler<String>("", null);
new Filler<String>(null, Side.LEFT);
}
@Test
public void testFillString() {
assertEquals(CAMPO + "00000", zeroRight.fill(CAMPO, TAMANHO));
assertEquals("00000" + CAMPO, zeroLeft.fill(CAMPO, TAMANHO));
}
@Test
public void testFillLong() {
assertEquals(1L + "000000000", zeroRight.fill(1L, TAMANHO));
assertEquals("000000000" + 1L, zeroLeft.fill(1L, TAMANHO));
}
@Test
public void testFillInt() {
assertEquals(1 + "000000000", zeroRight.fill(1, TAMANHO));
assertEquals("000000000" + 1, zeroLeft.fill(1, TAMANHO));
}
@Test
public void testFillShort() {
assertEquals((short) 1 + "000000000", zeroRight.fill((short) 1,
TAMANHO));
assertEquals("000000000" + (short) 1, zeroLeft.fill((short) 1,
TAMANHO));
}
@Test
public void testFillByte() {
assertEquals((byte) 1 + "000000000", zeroRight.fill((byte) 1,
TAMANHO));
assertEquals("000000000" + (byte) 1, zeroLeft.fill((byte) 1,
TAMANHO));
}
@Test
public void testFillChar() {
assertEquals('1' + "000000000", zeroRight.fill('1', TAMANHO));
assertEquals("000000000" + '1', zeroLeft.fill('1', TAMANHO));
}
@Test
public void testFillDouble() {
assertEquals(1.0 + "0000000", zeroRight.fill(1.0, TAMANHO));
assertEquals("0000000" + 1.0, zeroLeft.fill(1.0, TAMANHO));
}
@Test
public void testFillFloat() {
assertEquals(1.0f + "0000000", zeroRight.fill(1.0f, TAMANHO));
assertEquals("0000000" + 1.0f, zeroLeft.fill(1.0f, TAMANHO));
}
@Test
public void testFillObject() {
Object object = new Object() {
@Override
public String toString() {
return CAMPO;
}
};
assertEquals(object + "00000", zeroRight.fill(object, TAMANHO));
assertEquals("00000" + object, zeroLeft.fill(object, TAMANHO));
}
@Test
public void testFillITextStream() {
TextStream textStream = new TextStream() {
private static final long serialVersionUID = 1L;
public void read(String g) {
}
public String write() {
return CAMPO;
}
};
assertEquals(textStream.write() + "00000", zeroRight.fill(
textStream, TAMANHO));
assertEquals("00000" + textStream.write(), zeroLeft.fill(
textStream, TAMANHO));
}
@Test
public void testFill() {
fillerString = new Filler<String>("ABC", Side.LEFT);
assertTrue(fillerString.getPadding() instanceof String);
assertEquals("ABCAB" + CAMPO, fillerString.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerString.fill(CAMPO, 0));
assertEquals(CAMPO, fillerString.fill(CAMPO, -TAMANHO));
fillerString.setSideToFill(Side.RIGHT);
assertEquals(CAMPO + "ABCAB", fillerString.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerString.fill(CAMPO, 0));
assertEquals(CAMPO, fillerString.fill(CAMPO, -TAMANHO));
fillerInteger = new Filler<Integer>(new Integer(TAMANHO),
Side.LEFT);
assertTrue(fillerInteger.getPadding() instanceof Integer);
assertEquals("10101" + CAMPO, fillerInteger.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerInteger.fill(CAMPO, 0));
assertEquals(CAMPO, fillerInteger.fill(CAMPO, -TAMANHO));
fillerInteger.setSideToFill(Side.RIGHT);
assertEquals(CAMPO + "10101", fillerInteger.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerInteger.fill(CAMPO, 0));
assertEquals(CAMPO, fillerInteger.fill(CAMPO, -TAMANHO));
fillerDouble = new Filler<Double>(new Double(10.9), Side.LEFT);
assertTrue(fillerDouble.getPadding() instanceof Double);
assertEquals("10.91" + CAMPO, fillerDouble.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerDouble.fill(CAMPO, 0));
assertEquals(CAMPO, fillerDouble.fill(CAMPO, -TAMANHO));
fillerDouble.setSideToFill(Side.RIGHT);
assertEquals(CAMPO + "10.91", fillerDouble.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerDouble.fill(CAMPO, 0));
assertEquals(CAMPO, fillerDouble.fill(CAMPO, -TAMANHO));
fillerSide = new Filler<Side>(Side.LEFT, Side.LEFT);
assertTrue(fillerSide.getPadding() instanceof Side);
assertEquals("LEFTL" + CAMPO, fillerSide.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerSide.fill(CAMPO, 0));
assertEquals(CAMPO, fillerSide.fill(CAMPO, -TAMANHO));
fillerSide.setSideToFill(Side.RIGHT);
assertEquals(CAMPO + "LEFTL", fillerSide.fill(CAMPO, TAMANHO));
assertEquals(CAMPO, fillerSide.fill(CAMPO, 0));
assertEquals(CAMPO, fillerSide.fill(CAMPO, -TAMANHO));
}
}

View File

@ -0,0 +1,228 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 30/03/2008 - 18:15:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 30/03/2008 - 18:15:56
*
*/
package org.jrimum.texgit.type.component;
import static org.jrimum.utilix.text.DateFormat.DDMMYYYY_B;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.lang.StringUtils;
import org.jrimum.utilix.Dates;
import org.jrimum.utilix.text.DecimalFormat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* <p>
* Teste unitário para a classe utilitária de coleções.
* </p>
*
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
* @author <a href="mailto:romulomail@gmail.com">Rômulo Augusto</a>
*
* @since 0.2
*
* @version 0.2
*/
public class TestFixedField {
private static final DateFormat FORMAT_DDMMYY = new SimpleDateFormat("ddMMyy");
private FixedField<String> campoString;
private FixedField<Integer> campoInteger;
private FixedField<Long> campoLong;
private FixedField<Date> campoDate;
private FixedField<BigDecimal> campoDecimal;
private FixedField<BigDecimal> campoDecimal_v9;
@Before
public void setUp() {
campoString = new FixedField<String>(StringUtils.EMPTY, 8, Fillers.WHITE_SPACE_RIGHT);
campoDate = new FixedField<Date>(DDMMYYYY_B.parse("22/07/2007"), 6, FORMAT_DDMMYY);
campoInteger = new FixedField<Integer>(0, 6, Fillers.ZERO_LEFT);
campoLong = new FixedField<Long>(0L, 6, Fillers.ZERO_LEFT);
campoDecimal = new FixedField<BigDecimal>(new BigDecimal("875.98"), 11, DecimalFormat.NUMBER_DD_BR.copy(), Fillers.ZERO_LEFT);
campoDecimal_v9 = new FixedField<BigDecimal>(new BigDecimal("875.9"), 10, DecimalFormat.NUMBER_D_BR.copy(), Fillers.ZERO_LEFT);
}
@After
public void tearDown() {
campoString = null;
campoDate = null;
campoInteger = null;
campoLong = null;
campoDecimal = null;
campoDecimal_v9 = null;
}
@Test(expected = IllegalArgumentException.class)
public void testCampo() {
Format format = null;
campoDate = new FixedField<Date>(new Date(), 0, FORMAT_DDMMYY);
campoDate = new FixedField<Date>(null, 1, FORMAT_DDMMYY);
campoDate = new FixedField<Date>(new Date(), 0, format);
}
@Test
public void testLer() {
campoString.read("COBRANCA");
assertNotNull(campoString.getValue());
assertTrue(campoString.getValue() instanceof String);
assertEquals("COBRANCA", campoString.getValue().toString());
campoDate.read("011002");
assertNotNull(campoDate.getValue());
assertTrue(campoDate.getValue() instanceof Date);
assertEquals("011002", FORMAT_DDMMYY.format(campoDate
.getValue()));
campoInteger.read("000001");
assertNotNull(campoInteger.getValue());
assertTrue(campoInteger.getValue() instanceof Integer);
assertTrue(new Integer(1).compareTo(campoInteger.getValue()) == 0);
campoLong.read("000001");
assertNotNull(campoLong.getValue());
assertTrue(campoLong.getValue() instanceof Long);
assertTrue(new Long(1L).compareTo(campoLong.getValue()) == 0);
campoDecimal.read("00000087598");
assertNotNull(campoDecimal.getValue());
assertTrue(campoDecimal.getValue() instanceof BigDecimal);
assertTrue(new BigDecimal("875.98").compareTo(campoDecimal.getValue()) == 0);
campoDecimal_v9.read("0000008759");
assertNotNull(campoDecimal_v9.getValue());
assertTrue(campoDecimal_v9.getValue() instanceof BigDecimal);
assertTrue(new BigDecimal("875.9").compareTo(campoDecimal_v9
.getValue()) == 0);
}
@Test(expected = IllegalArgumentException.class)
public void testLerException() {
campoString.read(null);
campoDate.read(null);
campoDate.read("");
campoDate.read("abcd");
campoDate.read("1a2MA1205");
}
@Test
public void testEscrever() {
assertNotNull(campoString.write());
assertEquals(" ", campoString.write());
assertEquals(8, campoString.write().length());
assertNotNull(campoDate.write());
assertEquals("220707", campoDate.write());
assertEquals(6, campoDate.write().length());
campoDate.setValue(Dates.invalidDate());
campoDate.setFiller(Fillers.ZERO_LEFT);
assertNotNull(campoDate.write());
assertEquals("000000", campoDate.write());
assertEquals(6, campoDate.write().length());
assertNotNull(campoInteger.write());
assertEquals("000000", campoInteger.write());
assertEquals(6, campoInteger.write().length());
assertNotNull(campoLong.write());
assertEquals("000000", campoLong.write());
assertEquals(6, campoLong.write().length());
assertNotNull(campoDecimal.write());
assertEquals("00000087598", campoDecimal.write());
assertEquals(11, campoDecimal.write().length());
assertNotNull(campoDecimal_v9.write());
assertEquals("0000008759", campoDecimal_v9.write());
assertEquals(10, campoDecimal_v9.write().length());
}
@Test(expected = IllegalStateException.class)
public void testEscreverException() {
FixedField<String> campo = new FixedField<String>("tamanho", 5);
assertEquals(5, campo.write().length());
FixedField<Integer> campo1 = new FixedField<Integer>(1234, 3);
assertEquals(3, campo1.write().length());
FixedField<Integer> campo2 = new FixedField<Integer>(12, 3);
assertEquals(3, campo2.write().length());
}
@Test(expected = IllegalArgumentException.class)
public void testSetCampo() {
campoInteger.setValue(null);
}
@Test(expected = IllegalArgumentException.class)
public void testSetTamanhoZero() {
campoString.setFixedLength(0);
}
@Test(expected = IllegalArgumentException.class)
public void testSetTamanhoNegativo() {
campoString.setFixedLength(-1);
}
@Test(expected = IllegalArgumentException.class)
public void testSetFiller() {
campoString.setFiller(null);
}
}

View File

@ -0,0 +1,80 @@
/*
* Copyright 2008 JRimum Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* Created at: 30/03/2008 - 18:15:56
*
* ================================================================================
*
* Direitos autorais 2008 JRimum Project
*
* Licenciado sob a Licença Apache, Versão 2.0 ("LICENÇA"); você não pode usar
* esse arquivo exceto em conformidade com a esta LICENÇA. Você pode obter uma
* cópia desta LICENÇA em http://www.apache.org/licenses/LICENSE-2.0 A menos que
* haja exigência legal ou acordo por escrito, a distribuição de software sob
* esta LICENÇA se dará COMO ESTÁ, SEM GARANTIAS OU CONDIÇÕES DE QUALQUER
* TIPO, sejam expressas ou tácitas. Veja a LICENÇA para a redação específica a
* reger permissões e limitações sob esta LICENÇA.
*
* Criado em: 30/03/2008 - 18:15:56
*
*/
package org.jrimum.utilix.excludes;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.jrimum.texgit.type.FixedField;
import org.jrimum.texgit.type.component.Field;
/**
* <p>
* Classe para uso em testes com <code>Fields</code>.
* </p>
*
* @author <a href="http://gilmatryx.googlepages.com/">Gilmar P.S.L.</a>
*
* @since 0.2
*
* @version 0.2
*/
public class TestUtil {
public static <G> void testEscritaCampo(FixedField<G> campo, Class<G> tipo,
G valorDeEntrada, String strEsperada, int tamanho) {
// >>>
assertNotNull(campo);
assertTrue(tipo.isInstance(campo.getValue()));
assertEquals(valorDeEntrada, campo.getValue());
assertNotNull(campo.write());
assertEquals(strEsperada, campo.write());
assertTrue(tamanho == campo.getFixedLength());
assertTrue(tamanho == campo.write().length());
}
public static <G> void testLeituraCampo(Field<G> campo, Class<G> tipo,
G valorEsperado, String strDeEntrada) {
// <<<
campo.read(strDeEntrada);
assertTrue(tipo.isInstance(campo.getValue()));
if (campo.getValue() instanceof Date)// compareNoFormatoEscrito
assertEquals(campo.getFormatter().format(valorEsperado), campo.write());
else
assertEquals(valorEsperado, campo.getValue());
}
}