diff --git a/.classpath b/.classpath
deleted file mode 100644
index 706eb07..0000000
--- a/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
new file mode 100644
index 0000000..85b8f0a
--- /dev/null
+++ b/.github/workflows/maven.yml
@@ -0,0 +1,28 @@
+name: Java CI
+
+on: [push]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4.2.2
+ - name: Set up JDK 1.8
+ uses: actions/setup-java@v4.5.0
+ with:
+ distribution: 'adopt'
+ java-version: 8.0.432+6
+ - name: Cache Maven packages
+ uses: actions/cache@v4.1.2
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+ - name: Build with Maven
+ run: mvn -V javadoc:javadoc -DadditionalJOption=-Xdoclint:none install --file pom.xml
+ # - name: Publish to personal mave repository
+ # env:
+ # GITHUB_TOKEN: ${{ github.token }}
+ # run: mvn -V javadoc:javadoc -DadditionalJOption=-Xdoclint:none deploy --file pom.xml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b52163d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/bin
+/target
+.classpath
+.DS_Store
+.project
+.settings
diff --git a/.project b/.project
deleted file mode 100644
index 7f06311..0000000
--- a/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- Utilix
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index b93d175..0000000
--- a/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Wed Mar 19 21:45:34 GMT-03:00 2008
-eclipse.preferences.version=1
-encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 2a26cc5..0000000
--- a/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Wed Nov 19 15:32:47 GMT-03:00 2008
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs
deleted file mode 100644
index d727c3b..0000000
--- a/.settings/org.eclipse.wst.validation.prefs
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Mar 18 17:15:50 GMT-03:00 2008
-DELEGATES_PREFERENCE=delegateValidatorListorg.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator\=org.eclipse.wst.wsdl.validation.internal.eclipse.Validator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator\=org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator;
-USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;
-USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.dtd.core.internal.validation.eclipse.Validator;org.eclipse.wst.xml.core.internal.validation.eclipse.Validator;org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator;org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator;org.eclipse.wst.xsd.core.internal.validation.eclipse.XSDDelegatingValidator;org.eclipse.wst.wsi.ui.internal.WSIMessageValidator;org.eclipse.jst.jsf.validation.internal.appconfig.AppConfigValidator;org.eclipse.wst.wsdl.validation.internal.eclipse.WSDLDelegatingValidator;org.eclipse.jst.jsf.validation.internal.JSPSemanticsValidator;org.eclipse.wst.html.internal.validation.HTMLValidator;
-USER_PREFERENCE=overrideGlobalPreferencesfalse
-eclipse.preferences.version=1
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..255285e
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,9 @@
+Utilix Changelog
+=============================
+
+0.2.3 (2014/02/01) suport bopepo-0.2.3
+---------------------------------------
+
+**Improvement**
+
+ * #2: Remover classes relacionadas a LineOfFields
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..37ec93a
--- /dev/null
+++ b/LICENSE
@@ -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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c2f928d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+Utilix
+======
+
+Utilitários usados no projeto [Lançado embutido, incubado]
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..bac8f63
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,241 @@
+
+
+ 4.0.0
+ org.jrimum
+ jrimum-utilix
+ jar
+ Projeto Utilix
+ 0.2.3
+ Projeto open source de componentes de software para o domínio de negócios do Brasil.
+ http://www.jrimum.org/utilix
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ Projeto JRimum
+ http://www.jrimum.org
+
+
+
+ GitHub
+ https://github.com/jrimum/utilix/issues
+
+
+
+ http://github.com/jrimum/utilix
+
+
+
+
+ Gilmar P. S. L.
+ gilmatryx@gmail.com
+
+
+ Misael Barreto
+ misaelbarreto@gmail.com
+
+
+ Rômulo Augusto
+ romulomail@gmail.com
+
+
+
+
+ UTF-8
+ UTF-8
+
+ gilbertoca
+ mvn-artifact
+ main
+ github
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.11.0
+
+ 1.8
+ 1.8
+
+
+
+ org.codehaus.mojo
+ animal-sniffer-maven-plugin
+ 1.6
+
+
+ org.codehaus.mojo.signature
+ java15
+ 1.0
+
+
+
+
+ animal-sniffer
+ compile
+
+ check
+
+
+
+
+
+ maven-assembly-plugin
+ 2.4
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.2.2
+
+ false
+
+ org/jrimum/utilix/**/*
+
+
+ org/jrimum/utilix/excludes/**/*
+ org/jrimum/utilix/**/*$*
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+ package
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.3.0
+
+
+ attach-javadoc
+ package
+
+ jar
+
+
+
+
+ UTF-8
+ UTF-8
+ true
+ private
+
+
+
+ com.github.github
+ site-maven-plugin
+ 0.12
+
+ Maven artifacts for ${project.version}
+ true
+ ${project.build.directory}/mvn-artifact
+ refs/heads/${branch-name}
+
+ **/*
+
+ true
+ ${repository-name}
+ ${repository-owner}
+ ${github.global.server}
+
+
+
+
+ site
+
+ deploy
+
+
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+
+ internal.repo::default::file://${project.build.directory}/mvn-artifact
+
+
+
+
+
+
+
+
+ commons-lang
+ commons-lang
+ 2.4
+
+
+
+ log4j
+ log4j
+ 1.2.15
+
+
+ mail
+ javax.mail
+
+
+ jms
+ javax.jms
+
+
+ jmxtools
+ com.sun.jdmk
+
+
+ jmxri
+ com.sun.jmx
+
+
+
+
+
+ junit
+ junit
+ 4.11
+ test
+
+
+
+
+
+ PROJECT-REPO-URL
+ https://github.com/${repository-owner}/${repository-name}/${branch-name}
+
+ true
+ always
+
+
+
+
+
+
+ internal.repo
+ Temporary Staging Repository
+ file://${project.build.directory}/mvn-artifact
+
+
+
+
diff --git a/src/br/com/nordestefomento/jrimum/JRimumException.java b/src/br/com/nordestefomento/jrimum/JRimumException.java
deleted file mode 100644
index 4c4b576..0000000
--- a/src/br/com/nordestefomento/jrimum/JRimumException.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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 - 16:16:24
- *
- * ================================================================================
- *
- * 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 - 16:16:24
- *
- */
-
-
-package br.com.nordestefomento.jrimum;
-
-
-/**
- *
- * Classe que representa um problema ocorrido dentro de qualquer parte (pacote)
- * do projeto JRimum
- *
- *
- *
- *
- * Qualquer exceção que ocorra dentro do componente JRimum é sempre
- * wrapped por uma instância de uma JRimumException.
- *
-JRimum é um projeto fruto da iniciativa conjunta entre Grupo JRimum e a Nordeste Fomento Mercantil
-objetivando a criação de componentes reutilizáveis Java com foco no domínio de negócios do Brasil.
-
-
-
-
-
-
-
-
- Bopepo é o primeiro componente disponibilizado pelo projeto com a finalidade de gerar boletos bancários.
-
-
-A biblioteca é focada em negócios,mas também contém classes utilitárias de propósito geral.
-
-
-
-
diff --git a/src/br/com/nordestefomento/jrimum/package.html b/src/br/com/nordestefomento/jrimum/package.html
deleted file mode 100644
index 5e4eb1c..0000000
--- a/src/br/com/nordestefomento/jrimum/package.html
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-Este pacote contém as classes e interfaces que devem ser herdadas e impelementadas por qualquer outra classe ou interface deste projeto.
-
-
diff --git a/src/br/com/nordestefomento/jrimum/utilix/AbstractLineOfFields.java b/src/br/com/nordestefomento/jrimum/utilix/AbstractLineOfFields.java
deleted file mode 100644
index ce94fea..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/AbstractLineOfFields.java
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * 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:32
- *
- * ================================================================================
- *
- * 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:32
- *
- */
-
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNotNull;
-
-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.apache.log4j.Logger;
-
-
-/**
- *
- * Descrição:
- *
- *
- * @author Gilmar P.S.L
- * @author Misael Barreto
- * @author Rômulo Augusto
- * @author Nordeste Fomento
- * Mercantil
- *
- * @since 0.2
- *
- * @version 0.2
- */
-public abstract class AbstractLineOfFields implements TextStream, List> {
-
- //TODO implementar isConsistent para os methods do tipo List em função de fieldsLength e stringLength.
-
- /**
- *
- */
- private static final long serialVersionUID = 9071816265288953266L;
-
- private static Logger log = Logger.getLogger(AbstractLineOfFields.class);
-
- /**
- *
- */
- private Integer fieldsLength;
-
- /**
- *
- */
- private Integer stringLength;
-
- /**
- *
- */
- private List> fields;
-
-
- /**
- * @param fieldsLength
- * @param stringLength
- */
- public AbstractLineOfFields(Integer fieldsLength, Integer stringLength) {
-
- if(log.isTraceEnabled())
- log.trace("Initializing");
-
- if(log.isDebugEnabled()){
- log.debug("Parameters fieldsLength: "+fieldsLength);
- log.debug("Parameters stringLength: "+stringLength);
- }
-
- if(isNotNull(fieldsLength, "fieldsLength") && isNotNull(stringLength, "stringLength")){
-
- if(fieldsLength > 0){
- if(stringLength > 0){
-
- fields = new ArrayList>(fieldsLength);
-
- this.fieldsLength = fieldsLength;
- this.stringLength = stringLength;
-
- }else{
-
- IllegalArgumentException e = new IllegalArgumentException("O tamanho da String [ " + stringLength + " ] deve ser maior que 0!");
-
- log.error(StringUtils.EMPTY, e);
-
- throw e;
- }
- }else{
-
- IllegalArgumentException e = new IllegalArgumentException("O tamanho dos campos [ " + fieldsLength + " ] deve ser maior que 0!");
-
- log.error(StringUtils.EMPTY, e);
-
- throw e;
- }
-
-
- }
-
- if(log.isTraceEnabled())
- log.trace("LineOfFields Initialized.");
-
- if(log.isDebugEnabled()){
- log.debug("Instance fieldsLength: "+fieldsLength);
- log.debug("Instance stringLength: "+stringLength);
- }
-
- }
-
- /**
- * @param lineOfFields
- */
- public void read(String lineOfFields){
-
- if(isNotNull(lineOfFields, "lineOfFields")){
-
- isConsistent(lineOfFields);
-
- StringBuilder builder = new StringBuilder(lineOfFields);
-
- for(Field> field : fields){
-
- field.read(builder.substring(0, field.getLength()));
- builder.delete(0, field.getLength());
- }
-
- builder = null;
- }
- }
-
- public String write(){
-
- StringBuilder lineOfFields = new StringBuilder(StringUtils.EMPTY);
-
- if(isNotNull(fields,"fields")){
-
- for(Field> field : fields)
- lineOfFields.append(field.write());
-
- isConsistent(lineOfFields);
-
- }
-
- return lineOfFields.toString();
- }
-
- protected final boolean isConsistent(StringBuilder lineOfFields){
- boolean is = false;
-
- if(isConsistent(lineOfFields.toString())){
- if(fieldsLength == size()){
- is = true;
- }else{
- IllegalStateException e = new IllegalStateException("O tamanho dos campos [ " + size() + " ] é incompatível com o especificado ["+fieldsLength+"]!");
-
- log.error(StringUtils.EMPTY, e);
-
- throw e;
- }
- }
- return is;
- }
-
- protected final boolean isConsistent(String lineOfFields){
- boolean is = false;
-
- if(lineOfFields.length() == stringLength){
- is = true;
- }else{
- IllegalStateException e = new IllegalStateException("O tamanho da String de campos [ " + lineOfFields.length() + " ] é incompatível com o especificado ["+stringLength+"]!");
-
- log.error(StringUtils.EMPTY, e);
-
- throw e;
- }
- return is;
- }
-
- /**
- * @return length of line as string.
- */
- public int stringSize(){
-
- return write().length();
- }
-
- /**
- * @return the fieldsLength
- */
- public Integer getFieldsLength() {
- return fieldsLength;
- }
-
- /**
- * @param fieldsLength the fieldsLength to set
- */
- public void setFieldsLength(Integer fieldsLength) {
- this.fieldsLength = fieldsLength;
- }
-
- /**
- * @return the stringLength
- */
- public Integer getStringLength() {
- return stringLength;
- }
-
- /**
- * @param stringLength the stringLength to set
- */
- public void setStringLength(Integer stringLength) {
- this.stringLength = stringLength;
- }
-
- /**
- * @see java.util.List#add(java.lang.Object)
- */
-
- public boolean add(Field> e) {
-
- return fields.add(e);
- }
-
- /**
- * @see java.util.List#add(int, java.lang.Object)
- */
-
- public void add(int index, Field> element) {
-
- fields.add(index, element);
- }
-
- /**
- * @see java.util.List#addAll(java.util.Collection)
- */
-
- public boolean addAll(Collection extends Field>> c) {
-
- return fields.addAll(c);
- }
-
- /**
- * @see java.util.List#addAll(int, java.util.Collection)
- */
-
- public boolean addAll(int index, Collection extends Field>> 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 Field> 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> 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> listIterator() {
-
- return fields.listIterator();
- }
-
- /**
- * @see java.util.List#listIterator(int)
- */
-
- public ListIterator> listIterator(int index) {
-
- return fields.listIterator(index);
- }
-
- /**
- * @see java.util.List#remove(int)
- */
-
- public Field> 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 Field> set(int index, Field> 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> 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[] toArray(T[] a) {
-
- return fields.toArray(a);
- }
-
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/BancoUtil.java b/src/br/com/nordestefomento/jrimum/utilix/BancoUtil.java
deleted file mode 100644
index dcaa4fd..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/BancoUtil.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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:40
- *
- * ================================================================================
- *
- * 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:40
- *
- */
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNull;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.apache.commons.lang.time.DateUtils;
-
-import br.com.nordestefomento.jrimum.JRimumException;
-
-/**
- *
- * Esta classe tem a responsabilidade de prover serviços utilitários
- * do universo bancário, como por exemplo calcular o fator de vencimento.
- *
- * Data base para o cálculo do fator de vencimento fixada em 07.10.1997
- * (03.07.2000 retrocedidos 1000 dias do início do processo) segundo a FEBRABAN.
- *
- */
- private static final Date DATA_BASE_DO_FATOR_DE_VENCIMENTO = new GregorianCalendar(1997, Calendar.OCTOBER, 7).getTime();
-
- private static final Date DATA_LIMITE_DO_FATOR_DE_VENCIMENTO = new GregorianCalendar(2025, Calendar.FEBRUARY, 21).getTime();
-
- /**
- *
- *
- * Calcula o fator de vencimento, com base na subtração entre a
- * DATA DE VENCIMENTO do título e a DATA BASE , fixada em
- * 07.10.1997 (03.07.2000 retrocedidos 1000 dias do início do processo).
- * Trata-se de um referencial numérico de 4 dígitos, situado nas
- * quatro primeiras posições do campo “valor”, que representa a
- * quantidade de dias decorridos da data base à data de vencimento
- * do título.
- *
- *
- * Os bloquetos de cobrança emitidos a partir de 1º de setembro
- * de 2000 (primeiro dia útil = 03/07/2000 - SEGUNDA) OBRIGATORIAMENTE
- * devem conter essas características, para que quando
- * forem capturados pela rede bancária, os sistemas possam realizar
- * operação inversa, ou seja, adicionar à data base o fator de
- * vencimento capturado, obtendo, dessa forma, a data do
- * vencimento do bloqueto.
- *
- * Exemplos: 03/07/2000(Fator = 1000), 05/07/2000(Fator = 1002),
- * 01/05/2002 (Fator = 1667), 05/07/2000(Fator = 1002)
- * e 21/02/2025(Fator = 9999).
- *
- *
- *
- * Observações:
- *
- *
- * A data base para o cálculo do fator de vencimento é
- * 07/10/1997 (Fator de vencimento = 0).Caso a data de
- * vencimento seja anterior a data base, uma exceção do tipo
- * IllegalArgumentException será lançada.
- *
- *
- * A data limite para o cálculo do fator de vencimento é
- * 21/02/2025 (Fator de vencimento = 9999) Caso a data de
- * vencimento seja posterior a data limite, uma exceção do tipo
- * IllegalArgumentException será lançada.
- *
- *
- *
- *
- * @param dataVencimento - data de vencimento.
- * @return fator de vencimento.
- *
- * @throws JRimumException Caso alguma condição de entrada não seja respeitada.
- */
- public static int calculceFatorDeVencimento(Date dataVencimento) throws JRimumException {
-
- Date dataVencTruncada = null;
- int fator;
-
-
- if (isNull(dataVencimento)) {
- throw new JRimumException(new IllegalArgumentException("Impossível realizar o cálculo do fator" +
- " de vencimento de uma data nula."));
- }
- else {
- dataVencTruncada = DateUtils.truncate(dataVencimento, Calendar.DATE);
- if (
- dataVencTruncada.before(DATA_BASE_DO_FATOR_DE_VENCIMENTO)
- || dataVencTruncada.after(DATA_LIMITE_DO_FATOR_DE_VENCIMENTO)
- ) {
- throw new JRimumException(new IllegalArgumentException("Para o cálculo do fator de" +
- " vencimento se faz necessário informar uma data entre" +
- " " + DateUtil.FORMAT_DD_MM_YYYY.format(DATA_BASE_DO_FATOR_DE_VENCIMENTO) +
- " e " + DateUtil.FORMAT_DD_MM_YYYY.format(DATA_LIMITE_DO_FATOR_DE_VENCIMENTO)));
- }
- else {
- fator = (int)DateUtil.calculeDiferencaEmDias(DATA_BASE_DO_FATOR_DE_VENCIMENTO, dataVencTruncada);
- }
- }
-
- return fator;
- }
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/Field.java b/src/br/com/nordestefomento/jrimum/utilix/Field.java
deleted file mode 100644
index 0c747cf..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/Field.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * 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:16:48
- *
- * ================================================================================
- *
- * 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:16:48
- *
- */
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNotNull;
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNull;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.text.Format;
-import java.text.ParseException;
-import java.util.Date;
-
-import org.apache.commons.lang.StringUtils;
-
-
-/**
- *
- * Descrição:
- *
- *
- * @author Gilmar P.S.L
- * @author Misael Barreto
- * @author Rômulo Augusto
- * @author Nordeste Fomento
- * Mercantil
- *
- * @since 0.2
- *
- * @version 0.2
- */
-public class Field implements TextStream {
-
- /**
- *
- */
- private static final long serialVersionUID = -7432509456997808459L;
-
- /**
- *
- */
- private Integer length;
-
- /**
- *
- */
- private G value;
-
- /**
- * Formatador utilizado na leitura e na escrita do value. - Na leitura para realizar o parse da String. - Na escrita para transformar o objeto em uma String e assim ser possível tratá-la para ser escrita.
- *
- */
- private Format format;
-
- /**
- * Preenchedor do value utilizado na hora da escrita.
- */
- private Filler> filler;
-
- /**
- * Cria um Field sem um formatador. Isto significa que a leitura da String
- * pelo objeto criado será como uma atribuição simples.
- * @param value Valor do campo
- * @param length Tamanho que o value deve possuir.
- */
- public Field(G value, Integer length){
-
- setValue(value);
- setLength(length);
- }
-
- /**
- * Cria um Field com um formatador. Isto significa que a leitura da String pelo
- * objeto criado será de acordo com o formatador.
- * @param value Valor do campo
- * @param length tamanho do campo
- * @param format Formatador que irá formatar a String fornecida na leitura para o value
- * especificado.
- */
- public Field(G value, Integer length, Format format){
-
- setLength(length);
- setValue(value);
- setFormat(format);
- }
-
- /**
- * Cria um Field com um preenchedor. Este preenchedor é utilizado na escrita do
- * Field quado é necessário preencher com caracteres especificados até o length definido.
- *
- * @param value valor do campo
- * @param length tamaho do campo
- * @param filler preenchedor
- */
- public Field(G value, Integer length, Filler> filler){
-
- setLength(length);
- setValue(value);
- setFiller(filler);
- }
-
- /**
- * Cria um Field com um formatador e com um preenchedor.
- *
- * @param value Valor do campo
- * @param length Tamanho do campo
- * @param format Formatador que irá formatar a String fornecida na leitura para o value
- * especificado.
- * @param filler preenchedor
- */
- public Field(G value, Integer length, Format format, Filler> filler){
-
- setLength(length);
- setValue(value);
- setFormat(format);
- setFiller(filler);
- }
-
-
- /**
- * Converte a String fornecida para o value representado pelo objeto.
- *
- * A conversão é realizada a partir do formatador fornecido para o objeto. Se não houver
- * formatador a String fornecida será atribuída como o valor do value.
- *
- * @param valueAsString valor do campo como uma String
- */
- public void read(String valueAsString){
-
- if (isNull(valueAsString)) {
- throw new IllegalArgumentException("String inválida [ " + valueAsString + " ]!");
- }
-
- if (valueAsString.length() != length) {
- throw new IllegalArgumentException("O tamanho da String [ " + valueAsString + " ] é incompatível com o especificado [ "+length+" ]!");
- }
-
- if (value instanceof TextStream) {
- TextStream reader = (TextStream) value;
- reader.read(valueAsString);
-
- } else if (value instanceof BigDecimal) {
-
- readDecimalField(valueAsString);
-
- } else if (value instanceof Date) {
-
- readDateField(valueAsString);
-
- } else {
-
- readStringOrNumericField(valueAsString);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void readStringOrNumericField(String valueAsString) {
-
- Class> c = value.getClass();
-
- for (Constructor> cons : c.getConstructors()) {
-
- if (cons.getParameterTypes().length == 1){
- if (cons.getParameterTypes()[0].equals(String.class)){
- try {
-
- value = (G) cons.newInstance(valueAsString);
-
- } catch (IllegalArgumentException e) {
- errorG(e, valueAsString).printStackTrace();
- } catch (InstantiationException e) {
- errorG(e, valueAsString).printStackTrace();
- } catch (IllegalAccessException e) {
- errorG(e, valueAsString).printStackTrace();
- } catch (InvocationTargetException e) {
- errorG(e, valueAsString).printStackTrace();
- }
- }
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- private void readDateField(String valueAsString){
-
- try {
-
- value = (G) format.parseObject(valueAsString);
- }
- catch (ParseException e) {
-
- errorG(e, valueAsString);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void readDecimalField(String valueAsString){
-
- DecimalFormat decimalFormat = (DecimalFormat) format;
-
- try {
-
- Long parsedValue = (Long) format.parseObject(valueAsString);
- BigDecimal decimalValue = new BigDecimal(parsedValue.longValue());
- decimalValue = decimalValue.movePointLeft(decimalFormat.getMaximumFractionDigits());
-
- value = (G) decimalValue;
-
- }
- catch (ParseException e) {
-
- errorG(e, valueAsString);
- }
- }
-
- public String write(){
-
- String str = null;
-
- if (value instanceof TextStream) {
-
- TextStream its = (TextStream) value;
-
- str = its.write();
-
- } else if (value instanceof Date) {
-
- Date campoDate = (Date) value;
-
- if (campoDate.compareTo(DateUtil.DATE_NULL) == 0) {
- str = StringUtils.EMPTY;
-
- } else {
- str = format.format(value);
- }
-
- } else if (value instanceof BigDecimal) {
- str = StringUtils.replaceChars(value.toString(), ".", StringUtils.EMPTY);
-
- } else {
- str = value.toString();
- }
-
- str = fill(str);
-
- if (str.length() != length) {
- throw new IllegalArgumentException("O campo [ " + str
- + " ] é incompatível com o especificado [" + length + "]!");
- }
-
- return StringUtil.eliminateAccent(str).toUpperCase();
- }
-
- private String fill(String str) {
-
- if(isNotNull(filler)) {
- str = filler.fill(str, length);
- }
-
- return str;
- }
-
- public G getValue() {
- return value;
- }
-
-
- public void setValue(G field) {
-
- if (isNotNull(field)) {
- this.value = field;
-
- } else {
- throw new IllegalArgumentException("Campo inválido [" + field + "]!");
- }
-
- }
-
-
- public Integer getLength() {
- return length;
- }
-
-
- public void setLength(Integer length) {
-
- if (length > 0) {
- this.length = length;
-
- } else {
- throw new IllegalArgumentException("Tamanho inválido [ " + length + " ]!");
- }
-
- }
-
-
- public Format getFormat() {
- return format;
- }
-
- public void setFormat(Format format) {
-
- if (isNotNull(format)) {
- this.format = format;
-
- } else {
- throw new IllegalArgumentException("Formato inválido [ " + format + " ]!");
- }
- }
-
- public Filler> getFiller() {
- return filler;
- }
-
- public void setFiller(Filler> filler) {
-
- if(isNotNull(filler)) {
- this.filler = filler;
-
- } else {
- throw new IllegalArgumentException("Filler inválido [ " + filler + " ]!");
- }
- }
-
- private static Exception errorG(Exception e, String value){
-
- StackTraceElement[] stackTrace = e.getStackTrace();
- e = new RuntimeException("Problemas entre instância e valor: [ " + value + " ]!\nCausado por: "+e.getCause());
- e.setStackTrace(stackTrace);
-
- return e;
- }
-
- @Override
- public String toString() {
- return ObjectUtil.toString(this);
- }
-}
\ No newline at end of file
diff --git a/src/br/com/nordestefomento/jrimum/utilix/FileUtil.java b/src/br/com/nordestefomento/jrimum/utilix/FileUtil.java
deleted file mode 100644
index f746192..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/FileUtil.java
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- * 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:54
- *
- * ================================================================================
- *
- * 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:54
- *
- */
-
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNotNull;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-/**
- *
- * Descrição:
- *
- *
- * @author Gilmar P.S.L
- * @author Misael Barreto
- * @author Rômulo Augusto
- * @author Nordeste Fomento
- * Mercantil
- *
- * @since 0.2
- *
- * @version 0.2
- */
-public class FileUtil {
-
- //TODO Criar Metodo que recebe um arquivo e coisas para verificar nele, como: (isVazio,Numero de linhas, etc)
-
- protected static final Logger LOG = Logger.getLogger(FileUtil.class);
-
- /**
- *
- */
- private static final long serialVersionUID = 1227314921804015225L;
-
- private static final int EOF = -1;
-
- private static final int CARRIAGE_RETURN = 1;
-
- private static final int NEXT_LINE = 2;
-
- private static final String NEW_LINE = "\r\n";
-
- /**
- * Retorna o conteúdo de um arquivo em um array de bytes.
- *
- * @param file
- * @return Array de bytes com o conteúdo de um File
- * @throws IOException
- */
- public static byte[] bytesFromFile(File file) throws IOException {
-
-
- byte[] bytes = null;
-
- if(isNotNull(file)){
-
- // medida do arquivo
- long length = file.length();
-
- // Nao se pode criar um array usando o tipo long.
- // Tem que ser int.
- // Antes de converter para o tipo int cheque
- // para assegurar que file.lenth não é maior que Integer.MAX_VALUE.
- if (length <= Integer.MAX_VALUE) {
-
- InputStream is = new FileInputStream(file);
-
- // para os dados
- bytes = new byte[(int) length];
-
- // leitura dos bytes
- int offset = 0;
- int numRead = 0;
-
- while ((offset < bytes.length)
- && ((numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)) {
- offset += numRead;
- }
-
- // Assegurando que todos os dados foram lidos
- if (offset < bytes.length) {
- throw new IOException("Não foi possível ler completamente o arquivo. ["
- + file.getName() + "]");
- }
-
- // Feche o input stream
- is.close();
-
- }else
- throw new IOException("O arquivo é muito grande para esta transformação.");
-
- }
-
- return bytes;
- }
-
- /**
- * Transforma um array de bytes em um arquivo.
- *
- * @param pathName
- * @param bytes
- * @return Objeto File com o conteúdo sendo o dos bytes
- * @throws FileNotFoundException
- * @throws IOException
- */
- public static File bytes2File(String pathName, byte[] bytes) throws FileNotFoundException, IOException {
-
- File f = null;
-
- if(isNotNull(pathName,"pathName") && isNotNull(bytes,"bytes")){
-
- f = new File(pathName);
-
- OutputStream out = new FileOutputStream(f);
-
- out.write(bytes);
- out.flush();
- out.close();
- }
-
- return f;
- }
-
-
-
- /**
- *
- * Transforma um array de bytes em um ByteArrayOutputStream.
- *
- *
- * @param bytes
- * @return ByteArrayOutputStream ou null
- * @throws IOException
- *
- * @since
- */
- public static ByteArrayOutputStream bytes2Stream(byte[] bytes) throws IOException{
-
- ByteArrayOutputStream byteOut = null;
-
- if(isNotNull(bytes,"bytes")){
-
- byteOut = new ByteArrayOutputStream();
-
- byteOut.write(bytes);
- }
-
- return byteOut;
- }
-
- public static String readLine(File file, int lengthOfBlock,
- int lineOrdinalNumber) {
-
- long position = 0;
-
- FileChannel fc = null;
- ByteBuffer bybff = null;
-
- String line = null;
-
- if (lengthOfBlock > 0) {
- if (lineOrdinalNumber > 0) {
-
- fc = getReadFileChannel(file);
-
- try {
-
- if (fc.size() > 0) {
-
- lengthOfBlock += NEXT_LINE;
-
- bybff = ByteBuffer.allocate(lengthOfBlock
- - CARRIAGE_RETURN);
-
- position = ((lineOrdinalNumber - 1) * lengthOfBlock);
-
- fc.position(position);
-
- fc.read(bybff);
-
- line = new String(bybff.array());
-
- fc.close();
-
- } else
- throw new IllegalArgumentException("file : [" + file
- + "] is empty!");
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else
- throw new IllegalArgumentException("lineOrdinalNumber : ["
- + lineOrdinalNumber + "] deve ser > 0!");
- } else
- throw new IllegalArgumentException("lengthOfBlock : ["
- + lengthOfBlock + "] deve ser > 0!");
-
- return line;
- }
-
- public static List readLines(File file, int lengthOfBlock) {
-
- FileChannel fc = null;
- ByteBuffer bybff = null;
-
- List blocks = null;
-
- if (lengthOfBlock > 0) {
-
- fc = getReadFileChannel(file);
-
- try {
-
- if (fc.size() > 0) {
-
- lengthOfBlock += CARRIAGE_RETURN;
-
- bybff = ByteBuffer
- .allocate(lengthOfBlock - CARRIAGE_RETURN);
-
- blocks = new ArrayList(getNumberOfLines(fc,
- lengthOfBlock));
-
- while (fc.read(bybff) != EOF) {
-
- blocks.add(new String(bybff.array()));
-
- fc.position(fc.position() + NEXT_LINE);
-
- bybff.clear();
- }
-
- fc.close();
-
- } else
- throw new IllegalArgumentException("file : [" + file
- + "] está vazio!");
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else
- throw new IllegalArgumentException("lengthOfBlock : ["
- + lengthOfBlock + "] deve ser > 0!");
-
- return blocks;
- }
-
- public static void writeLines(File file, List lines){
-
- FileChannel fc = null;
- ByteBuffer bybff = null;
- ByteBuffer[] bybffArray = null;
- String line = null;
-
- if(isNotNull(lines) && !lines.isEmpty()){
-
- bybffArray = new ByteBuffer[lines.size()];
-
- for(int i = 0 ; i < lines.size(); i++){
-
- line = lines.get(i);
-
- bybff = ByteBuffer.allocate(line.length() + NEXT_LINE);
-
- line += NEW_LINE;
-
- bybff.put(line.getBytes());
- bybff.rewind();
-
- bybffArray[i] = bybff;
- }
-
- fc = getWriteFileChannel(file);
-
- try {
-
- fc.write(bybffArray);
- fc.close();
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- public static boolean isEmpty(File file){
-
- boolean is = true;
-
- if(isNotNull(file)){
- is = (file.length() > 0);
- }else
- throw new IllegalArgumentException("file : [" + file + "]!");
-
- return is;
- }
-
- public static int getNumberOfLines(File file, int lengthOfBlock) {
-
- int size = 0;
-
- if (lengthOfBlock > 0) {
-
- size = getNumberOfLines(getReadFileChannel(file), lengthOfBlock);
-
- } else
- throw new IllegalArgumentException("lengthOfBlock : ["
- + lengthOfBlock + "] deve ser > 0!");
-
- return size;
- }
-
- public static int getNumberOfLines(FileChannel fileChannel, int lengthOfBlock) {
-
- int size = 0;
-
- if (isNotNull(fileChannel)) {
- if (lengthOfBlock > 0) {
-
- try {
-
- if (fileChannel.size() > 0) {
-
- lengthOfBlock += CARRIAGE_RETURN;
-
- size = (int) (fileChannel.size() / lengthOfBlock);
- }
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else
- throw new IllegalArgumentException("lengthOfBlock : ["
- + lengthOfBlock + "] deve ser > 0!");
- } else
- throw new IllegalArgumentException("fileChannel : [" + fileChannel
- + "]!");
-
- return size;
- }
-
- public static void copyTo(File fileIn, File fileOut){
-
- FileChannel fcin = getReadFileChannel(fileIn);
-
- FileChannel fcout = getWriteFileChannel(fileOut);
-
- try {
-
- fcin.transferTo(0, fcin.size(), fcout);
-
- fcin.close();
- fcout.close();
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public static FileChannel getReadFileChannel(File file) {
-
- FileInputStream fis = null;
- FileChannel fc = null;
-
- if (!isEmpty(file)) {
-
- try {
-
- fis = new FileInputStream(file);
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
-
- fc = fis.getChannel();
- }
-
- return fc;
- }
-
- public static FileChannel getWriteFileChannel(File file){
-
- FileOutputStream fos = null;
- FileChannel fc = null;
-
- if (!isEmpty(file)) {
-
- try {
-
- fos = new FileOutputStream(file);
-
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
-
- fc = fos.getChannel();
- }
-
- return fc;
- }
-
-
- public static List readFile(String pathName) {
-
- if (isNotNull(pathName)) {
-
- List lines = new ArrayList();
-
- try {
- File arq = new File(pathName);
-
- BufferedReader reader = new BufferedReader(new FileReader(arq));
-
- String s;
-
- do {
- s = reader.readLine();
- if (isNotNull(s)) {
- lines.add(s);
- }
- } while (isNotNull(s));
-
- reader.close();
-
- return lines;
-
- } catch (FileNotFoundException e) {
- LOG.error(" RECEBER PROCESSAMENTO "
- + "String pathNomeArquivo: " + pathName, e);
- } catch (IOException e) {
- LOG.error(" RECEBER PROCESSAMENTO "
- + "String pathNomeArquivo: " + pathName, e);
- }
- }
-
- return null;
- }
-
- public static List readFile(File file){
-
- List lines = null;
-
- if(!isEmpty(file)){
-
- try {
-
- lines = new ArrayList();
-
- BufferedReader reader = new BufferedReader(new FileReader(file));
-
- String s;
-
- do {
- s = reader.readLine();
- if (isNotNull(s)) {
- lines.add(s);
- }
- } while (isNotNull(s));
-
- reader.close();
-
- return lines;
-
- } catch (FileNotFoundException e) {
- LOG.error(" RECEBER PROCESSAMENTO ", e);
- } catch (IOException e) {
- LOG.error(" RECEBER PROCESSAMENTO ", e);
- }
- }
-
- return lines;
- }
-
- public static void markAs(String pathName, String tag) {
-
- if (isNotNull(pathName) & isNotNull(tag)) {
-
- File file = new File(pathName);
- File newFile = new File(pathName+tag);
-
- file.renameTo(newFile);
-
- }
- }
-
-
- public static boolean renameTo(String path, String name,String newName) {
-
- if (isNotNull(path) & isNotNull(name) & isNotNull(newName)) {
-
- File file = new File(path+"/"+name);
- File newFile = new File(path+"/"+newName);
-
- file.renameTo(newFile);
- return true;
- }
-
- return false;
- }
-
-
- public static void createTextFile(String pathName, String content) {
-
- if (LOG.isTraceEnabled())
- LOG.trace("Creating file...");
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("pathName: " + pathName);
- LOG.debug("content: " + content);
- }
-
- List line = new ArrayList(1);
- line.add(content);
-
- writeLines(new File(pathName), line);
- }
-
-
-
- public static void createTextFile(String pathName, List content ) {
-
- if (LOG.isTraceEnabled())
- LOG.trace("Creating file...");
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("pathName: " + pathName);
- LOG.debug("content: " + content);
- }
-
- writeLines(new File(pathName), content);
- }
-
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/Filler.java b/src/br/com/nordestefomento/jrimum/utilix/Filler.java
deleted file mode 100644
index 9d0bae5..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/Filler.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * 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 br.com.nordestefomento.jrimum.utilix;
-
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNotNull;
-import org.apache.commons.lang.StringUtils;
-
-
-/**
- *
- * Preenchedor de caracteres genérico. É utilizado para preencher objetos String,
- * 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 menor
- * ou igual a 0 (ZERO), este valor será desconsiderado e nada será preenchido.
- *
- *
- * É utilizado o método toString() do objeto preenchedor.
- *
- *
- * @author Gilmar P.S.L
- * @author Misael Barreto
- * @author Rômulo Augusto
- * @author Nordeste Fomento
- * Mercantil
- *
- * @since JRimum 1.0
- *
- * @version 0.2
- *
- */
-public class Filler {
-
- /**
- *
- */
- private static final long serialVersionUID = -3996934478582358340L;
-
- /**
- * Filler padrão para preenchimento com zeros a esquerda.
- */
- public static final Filler ZERO_LEFT = new Filler(0, SideToFill.LEFT);
-
- /**
- * Filler padrão para preenchimento com zeros a direita.
- */
- public static final Filler ZERO_RIGHT = new Filler(0, SideToFill.RIGHT);
-
- /**
- * Filler padrão para preenchimento com espaços em branco a esquerda.
- */
- public static final Filler WHITE_SPACE_LEFT = new Filler(StringUtil.WHITE_SPACE, SideToFill.LEFT);
-
- /**
- * Filler padrão para preenchimento com espaços em branco a direita.
- */
- public static final Filler WHITE_SPACE_RIGHT = new Filler(StringUtil.WHITE_SPACE, SideToFill.RIGHT);
-
- /**
- *
- */
- private G fillWith;
-
- /**
- *
- */
- private SideToFill sideToFill;
-
- /**
- * @param fillWith
- * @param sideToFill
- */
- public Filler(G fillWith, SideToFill sideToFill) {
-
- setFillWith(fillWith);
- setSideToFill(sideToFill);
- }
-
- public G getFillWith() {
- return fillWith;
- }
-
- /**
- * @param fillWith valor que preenche o real valor do campo
- */
- public void setFillWith(G fillWith) {
-
- if(isNotNull(fillWith))
- this.fillWith = fillWith;
-
- else
- throw new IllegalArgumentException("Filler inválido [ " + fillWith + " ]!");
- }
-
- /**
- * @return enum SideToFill
- */
- public SideToFill getSideToFill() {
- return sideToFill;
- }
-
- /**
- * @param sideToFill enum com a informaçao de qual lado a ser preenchido
- */
- public void setSideToFill(SideToFill sideToFill) {
-
- if(isNotNull(sideToFill))
- this.sideToFill = sideToFill;
-
- else
- throw new IllegalArgumentException("Lado inválido [ " + sideToFill + " ]!");
- }
-
- /**
- *
- * Preenche o campo com o caracter especificado e no lado especificado.
- *
- *
- * Exemplo:
- *
- * Se sideToFill == SideToFill.LEFT, o caracter especificado será adicionado à String
- * no lado esquerdo até que o campo fique com o tamanho que foi definido.
- *
- *
- * @param toFill String a ser preenchida
- * @param length tamanho máximo que a String deve ter depois de preenchida
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- */
- 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;
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como String.valueOf(toFill).
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(long toFill, int length){
- return fill(String.valueOf(toFill), length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como String.valueOf(toFill).
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(int toFill, int length){
- return fill(String.valueOf(toFill), length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como String.valueOf(toFill).
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(short toFill, int length){
- return fill(String.valueOf(toFill), length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como String.valueOf(toFill).
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(byte toFill, int length){
- return fill(String.valueOf(toFill), length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como String.valueOf(toFill).
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(char toFill, int length){
- return fill(String.valueOf(toFill), length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como String.valueOf(toFill).
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(double toFill, int length){
- return fill(String.valueOf(toFill), length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como String.valueOf(toFill).
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(float toFill, int length){
- return fill(String.valueOf(toFill), length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como toFill.toString().
- *
- *
- *
- * Caso toFill seja null, o método
- * fill(String, int) receberá uma String nula como parâmetro.
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(Object toFill, int length){
-
- String toFillTemp = null;
-
- if (isNotNull(toFill)) {
- toFillTemp = toFill.toString();
- }
-
- return fill(toFillTemp, length);
- }
-
- /**
- *
- *
- * Executa o método fill(String, int) passando o parâmetro
- * toFill como toFill.write().
- *
- *
- *
- * Caso toFill seja null, o método
- * fill(String, int) receberá uma String nula como parâmetro.
- *
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- *
- * @see Filler#fill(String, int)
- */
- public String fill(TextStream toFill, int length){
-
- String toFillTemp = null;
-
- if(isNotNull(toFill))
- toFillTemp = toFill.write();
-
- return fill(toFillTemp, length);
- }
-
- /**
- * Preenche a String a direita com valor do atributo "fillWith"
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- */
- private String fillRight(String toFill, int length) {
-
- return StringUtils.rightPad(toFill, length, fillWith.toString());
- }
-
- /**
- * Preenche a String a direita com valor do atributo "fillWith"
- *
- * @param toFill Valor a ser preenchido
- * @param length tamanho máximo que o valor deve ter depois de preenchido
- * @return Nova String preenchida de acordo com o preenchedor do objeto até o tamanho especificado
- */
- private String fillLeft(String toFill, int length) {
-
- return StringUtils.leftPad(toFill, length, fillWith.toString());
- }
-
- /**
- *
- * Lados para preencher.
- *
- */
- public enum SideToFill{
-
- LEFT,
- RIGHT;
- }
-
- @Override
- public String toString() {
- return ObjectUtil.toString(this);
- }
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/LocaleUtil.java b/src/br/com/nordestefomento/jrimum/utilix/LocaleUtil.java
deleted file mode 100644
index 2a3d54b..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/LocaleUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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: 04/04/2009 - 10:34:47
- *
- * ================================================================================
- *
- * 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: 04/04/2009 - 10:34:47
- *
- */
-package br.com.nordestefomento.jrimum.utilix;
-
-import java.util.Locale;
-
-/**
- *
- * @author Rômulo Augusto
- *
- * @version 0.2
- */
-public class LocaleUtil {
-
- public static final Locale PORTUGUESE = new Locale("pt");
-
- public static final Locale PORTUGAL = new Locale("pt", "PT");
-
- public static final Locale BRAZIL = new Locale("pt", "BR");
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/MonetaryUtil.java b/src/br/com/nordestefomento/jrimum/utilix/MonetaryUtil.java
deleted file mode 100644
index 063db6d..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/MonetaryUtil.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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:18: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:18:00
- *
- */
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
-import java.util.Locale;
-
-
-public class MonetaryUtil {
-
- /**
- *
- */
- private static final long serialVersionUID = 3239576826390112911L;
-
- /**
- * DecimalFormatSymbols com localização (Processo de localização) Brasil.
- */
- public static final DecimalFormatSymbols BRASIL_DECIMAL_SYMBOLS = new DecimalFormatSymbols(new Locale("pt", "BR"));
-
- /**
- * DecimalFormatSymbols com localização (Processo de localização) England.
- */
- public static final DecimalFormatSymbols ENGLAND_DECIMAL_SYMBOLS = new DecimalFormatSymbols(new Locale("en", "US"));
-
- /**
- * NumberFormat usado para formatar valores monetários em real.
- */
- public static final NumberFormat FORMAT_REAL = new DecimalFormat("#,##0.00", BRASIL_DECIMAL_SYMBOLS);
-
- /**
- * NumberFormat usado para formatar valores monetários em real com apenas UMA casa decimal.
- */
- public static final NumberFormat FORMAT_REAL_UMA_CASA_DECIMAL = new DecimalFormat("#,##0.0", BRASIL_DECIMAL_SYMBOLS);
-
- /**
- * NumberFormat usado para formatar valores monetários em real com o prefixo R$, exemplo: R$ 10,00.
- */
- public static final NumberFormat FORMAT_REAL_COM_PREFIXO = new DecimalFormat("R$ #,##0.00", BRASIL_DECIMAL_SYMBOLS);
-
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/ObjectUtil.java b/src/br/com/nordestefomento/jrimum/utilix/ObjectUtil.java
deleted file mode 100644
index 202ae9f..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/ObjectUtil.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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:02:40
- *
- * ================================================================================
- *
- * 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:02:40
- *
- */
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import java.io.Serializable;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.log4j.Logger;
-
-/**
- *
- *
- * Classe raiz para todo o projeto detentora de metodos básicos e necessários.
- *
- *
- *
- * Todas as classes do projeto devem herdar de ObjectUtil
- * para reutilizar métodos como o toString() e
- * isNull(Object, String).
- *
- * Verifica a referência ao objeto e lança uma exceção para casos onde a
- * referência é nula incluíndo na mensagem de exceção o nome do parâmetro
- * passado.
- *
- * Verifica a referência ao objeto e lança uma exceção para casos onde a
- * referência é nula incluíndo na mensagem de exceção o nome do parâmetro
- * passado.
- *
- *
- *
- * É o mesmo que usar !isNull(obj1,"obj1") a diferença é que
- * utiliza-se um símbolo ! a menos.
- *
- *
- * @param object
- *
- * @return (object == null ? true : false)
- *
- * @see #isNotNull(Object)
- *
- * @since 0.2
- */
- public static boolean isNull(Object object) {
- return (object == null);
- }
-
- /**
- * Exibe os valores de instância para um objeto JRimum.
- *
- * @see org.apache.commons.lang.builder.ToStringBuilder#reflectionToString
- *
- * @since 0.2
- *
- * @see #toString()
- */
- public static String toString(Object obj) {
- return "JRimumObject: " + ToStringBuilder.reflectionToString(obj);
- }
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/PDFUtil.java b/src/br/com/nordestefomento/jrimum/utilix/PDFUtil.java
deleted file mode 100644
index eb5945e..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/PDFUtil.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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 - 23:49: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 - 23:49:00
- *
- */
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
-import com.lowagie.text.Image;
-import com.lowagie.text.pdf.PdfCopy;
-import com.lowagie.text.pdf.PdfImportedPage;
-import com.lowagie.text.pdf.PdfReader;
-import com.lowagie.text.pdf.PdfStamper;
-import com.lowagie.text.pdf.SimpleBookmark;
-
-
-/**
- *
- *
- * DEFINIÇÃO DA CLASSE
- *
- *
- *
- * OBJETIVO/PROPÓSITO
- *
- *
- *
- * EXEMPLO:
- *
- *
- * @author Gilmar P.S.L.
- *
- * @since 0.2
- *
- * @version 0.2
- */
-
-public class PDFUtil {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- protected static final Logger LOG = Logger.getLogger(PDFUtil.class);
-
- public static RectanglePDF changeField2Image(PdfStamper stamper, float[] positions , Image image) throws DocumentException{
-
- RectanglePDF rect = new RectanglePDF(positions);
-
- return changeField2Image(stamper,rect,image);
- }
-
- public static RectanglePDF changeField2Image(PdfStamper stamper,
- RectanglePDF rect, Image image) throws DocumentException {
-
- // Ajustando o tamanho da imagem de acordo com o tamanho do campo.
- // image.scaleToFit(rect.getWidth(), rect.getHeight());
- image.scaleAbsolute(rect.getWidth(), rect.getHeight());
-
- // A rotina abaixo tem por objetivo deixar a imagem posicionada no
- // centro
- // do field, tanto na perspectiva horizontal como na vertical.
- // Caso não se queira mais posicionar a imagem no centro do field, basta
- // efetuar a chamada a seguir:
- // "image.setAbsolutePosition
- // (rect.getLowerLeftX(),rect.getLowerLeftY());"
- image.setAbsolutePosition(rect.getLowerLeftX()
- + (rect.getWidth() - image.getScaledWidth()) / 2, rect
- .getLowerLeftY()
- + (rect.getHeight() - image.getScaledHeight()) / 2);
-
- // cb = stamper.getUnderContent(rect.getPage());
- stamper.getOverContent(rect.getPage()).addImage(image);
-
- return rect;
- }
-
- /**
- * Junta varios arquivos pdf em um soh.
- *
- * @param pdfFiles Lista de array de bytes
- *
- * @return Arquivo PDF em forma de byte
- */
- @SuppressWarnings("unchecked")
- public static byte[] mergeFiles(List pdfFiles) {
-
- // retorno
- byte[] bytes = null;
-
- if (isNotNull(pdfFiles) && !pdfFiles.isEmpty()) {
-
- int pageOffset = 0;
- boolean first = true;
-
- ArrayList master = null;
- Document document = null;
- PdfCopy writer = null;
- ByteArrayOutputStream byteOS = null;
-
- try {
-
- byteOS = new ByteArrayOutputStream();
- master = new ArrayList();
-
- for (byte[] doc : pdfFiles) {
-
- if (isNotNull(doc)) {
-
- // cria-se um reader para cada documento
-
- PdfReader reader = new PdfReader(doc);
-
- if (reader.isEncrypted()) {
- reader = new PdfReader(doc, "".getBytes());
- }
-
- reader.consolidateNamedDestinations();
-
- // pega-se o numero total de paginas
- int n = reader.getNumberOfPages();
- List bookmarks = SimpleBookmark.getBookmark(reader);
-
- if (isNotNull(bookmarks)) {
- if (pageOffset != 0) {
- SimpleBookmark.shiftPageNumbers(bookmarks,
- pageOffset, null);
- }
- master.addAll(bookmarks);
- }
-
- pageOffset += n;
-
- if (first) {
-
- // passo 1: criar um document-object
- document = new Document(reader
- .getPageSizeWithRotation(1));
-
- // passo 2: criar um writer que observa o documento
- writer = new PdfCopy(document, byteOS);
- document.addAuthor("JRimum Group");
- document.addSubject("JRimum Merged Document");
- document.addCreator("JRimum Utilix");
-
- // passo 3: abre-se o documento
- document.open();
- first = false;
- }
-
- // passo 4: adciona-se o conteudo
- PdfImportedPage page;
- for (int i = 0; i < n;) {
- ++i;
- page = writer.getImportedPage(reader, i);
-
- writer.addPage(page);
- }
- }
- }
-
- if (master.size() > 0) {
- writer.setOutlines(master);
- }
-
- // passo 5: fecha-se o documento
- if (isNotNull(document)) {
- document.close();
- }
-
- bytes = byteOS.toByteArray();
-
- } catch (Exception e) {
- LOG.error("", e);
- }
- }
-
- return bytes;
- }
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/RectanglePDF.java b/src/br/com/nordestefomento/jrimum/utilix/RectanglePDF.java
deleted file mode 100644
index 33d3555..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/RectanglePDF.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package br.com.nordestefomento.jrimum.utilix;
-
-import com.lowagie.text.Rectangle;
-
-public class RectanglePDF extends Rectangle {
-
- private int page;
-
- /**
- * For each of this groups the values are: [page, llx, lly, urx, ury].
- */
- public RectanglePDF(float[] positions) {
- super(positions[1], positions[2], positions[3], positions[4]);
- page = (int) positions[0];
- }
-
-
- /**
- * @param arg0
- * @param arg1
- * @param arg2
- * @param arg3
- */
- public RectanglePDF(float arg0, float arg1, float arg2, float arg3) {
- super(arg0, arg1, arg2, arg3);
- }
-
- /**
- * @param arg0
- * @param arg1
- */
- public RectanglePDF(float arg0, float arg1) {
- super(arg0, arg1);
- }
-
- /**
- * @param arg0
- */
- public RectanglePDF(Rectangle arg0) {
- super(arg0);
- }
-
- public int getPage(){
- return page;
- }
-
-
- /**
- *
- * SOBRE O MÉTODO
- *
- *
- * @return llx - lower left x
- */
- public float getLowerLeftX(){
- return this.llx;
- }
-
- /**
- *
- * SOBRE O MÉTODO
- *
- *
- * @return lly - lower left y
- */
- public float getLowerLeftY(){
- return lly;
- }
-
- /**
- *
- * SOBRE O MÉTODO
- *
- *
- * @return urx - upper right x
- *
- */
- public float getUpperRightX(){
- return urx;
- }
-
-
- /**
- *
- * SOBRE O MÉTODO
- *
- *
- * @return ury - upper right y
- *
- * @since 1.0
- */
- public float getUpperRightY(){
- return ury;
- }
-
-}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/StringUtil.java b/src/br/com/nordestefomento/jrimum/utilix/StringUtil.java
deleted file mode 100644
index f3671e9..0000000
--- a/src/br/com/nordestefomento/jrimum/utilix/StringUtil.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * 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:18:19
- *
- * ================================================================================
- *
- * 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:18:19
- *
- */
-
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNotNull;
-
-import org.apache.commons.lang.StringUtils;
-
-
-/**
- *
- * Esta classe tem a responsabilidade de prover serviços utilitários
- * relacionados a manipulação de Strings
- *
- *
- *
- * @author Gilmar P.S.L
- * @author Misael Barreto
- * @author Rômulo Augusto
- * @author Nordeste Fomento Mercantil
- *
- * @since 0.2
- *
- * @version 0.2
- */
-public class StringUtil {
-
- public static final String WHITE_SPACE = " ";
-
- /**
- *
- */
- private static final long serialVersionUID = 7425529940068032055L;
-
- /**
- * Construtor privado que previne a instanciação da classe até por reflection
- */
- private StringUtil() {
- throw new AssertionError();
- }
-
- /**
- * Elimina simbolos como:
- * ><,;.:!*&%+-_<>[]\/
- *
- * @param str String com os símbolos a serem removidos.
- * @return String sem símbolos.
- */
- public static String eliminateSymbols(final String str){
-
- String modifiedStr = str;
-
- if(isNotNull(modifiedStr)){
-
- modifiedStr = StringUtils.replace(str,"-", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"_", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"=", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"+", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"%", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"*", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"@", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"#", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"&", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,":", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,".", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,";", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,",", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"!", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"?", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"(", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,")", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"{", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"}", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"[", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"]", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"/", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"\\", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,">", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"<", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"\"", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"'", StringUtils.EMPTY);
- modifiedStr = StringUtils.replace(str,"`", StringUtils.EMPTY);
- }
-
- return modifiedStr;
- }
-
-
- /**
- *
- * Remove os zeros iniciais de uma String, seja ela numérica ou não.
- *
-
-
-
diff --git a/src/main/java/org/jrimum/utilix/Arrays.java b/src/main/java/org/jrimum/utilix/Arrays.java
new file mode 100644
index 0000000..88ec658
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/Arrays.java
@@ -0,0 +1,412 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 21:30:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 21:30:00
+ *
+ */
+
+package org.jrimum.utilix;
+
+/**
+ *
+ * Classe utilitária para validações de arrays em geral.
+ *
+ *
+ *
+ * Inicialmente fornece métodos booleanos para verificação da existência de elementos.
+ *
+ *
+ * @author Gilmar P.S.L.
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public final class Arrays {
+
+ /**
+ * Utility class pattern: classe não instanciável
+ *
+ * @throws IllegalStateException
+ * Caso haja alguma tentativa de utilização deste construtor.
+ */
+ private Arrays() {
+
+ Exceptions.throwIllegalStateException("Instanciação não permitida!");
+ }
+
+ /**
+ *
+ * Indica se um dado array de chars tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(char[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de booleans tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a
+ * - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(boolean[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de bytes tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(byte[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de shorts tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(short[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de ints tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(int[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de longs tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(long[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de floats tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(float[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de doubles tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(double[] a){
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Indica se um dado array de objetos tem elementos sem gerar NPE.
+ *
+ *
+ * Resposta direta para o seguinte código:
+ * (a != null && a > 0).
+ *
+ *
+ * @param a - O array a ser testado.
+ *
+ * @return (a != null && a > 0)
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(Object[] a) {
+
+ return (a != null && a.length > 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(char[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(boolean[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(byte[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(short[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(int[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(long[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(float[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(double[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+ /**
+ *
+ * Retorna a quantidade de elementos de um dado array sem gerar NPE.
+ *
+ *
+ * Resposta direata para o seguinte código:
+ * (a != null ? a.length : 0).
+ *
+ *
+ * @param a
+ * - Array com ou sem elementos.
+ *
+ * @return (a != null ? a.length : 0)
+ */
+ public static int length(Object[] a){
+
+ return (a != null ? a.length : 0);
+ }
+
+}
diff --git a/src/main/java/org/jrimum/utilix/ClassLoaders.java b/src/main/java/org/jrimum/utilix/ClassLoaders.java
new file mode 100644
index 0000000..4e546ba
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/ClassLoaders.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2010 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: 27/10/2010 - 01:40:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 27/10/2010 - 01:40:00
+ *
+ */
+
+package org.jrimum.utilix;
+
+import static java.lang.String.format;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Utilitário para carregamento de recursos da apliacação por meio do classpath.
+ *
+ *
+ * @author Gilmar P.S.L.
+ */
+public final class ClassLoaders {
+
+ /**
+ * Utility class pattern: classe não instanciável
+ *
+ * @throws IllegalStateException
+ * Caso haja alguma tentativa de utilização deste construtor.
+ */
+ private ClassLoaders() {
+
+ Exceptions.throwIllegalStateException("Instanciação não permitida!");
+ }
+
+ /**
+ * Carrega um recurso existente no classpath.
+ *
+ * @param resourceName
+ * - O nome do resource a ser carregado
+ * @return URL para o recurso (resource).
+ */
+ public static URL getResource(String resourceName) {
+
+ return getResource(resourceName, null);
+ }
+
+ /**
+ * Carrega um recurso existente no classpath com ou sem uma classe
+ * informada.
+ *
+ *
+ * Informando a classe há necessidade de informar o caminho do pacote, caso
+ * o recurso esteja nele.
+ *
+ *
+ * @param resourceName
+ * - O nome do resource a ser carregado
+ * @param callingClass
+ * - A classe do objeto chamador ou outro.
+ * @return URL para o recurso (resource).
+ */
+ public static URL getResource(String resourceName, Class> callingClass) {
+
+ URL url = null;
+
+ if (callingClass != null) {
+
+ url = callingClass.getResource(resourceName);
+
+ if (url == null) {
+
+ url = callingClass.getClassLoader().getResource(resourceName);
+
+ }else{
+
+ return url;
+ }
+
+ if (url == null) {
+
+ String inPagckage = format("%s/%s", callingClass.getPackage().getName().replaceAll("\\.", "/"), resourceName);
+
+ url = Thread.currentThread().getContextClassLoader().getResource(inPagckage);
+
+ } else {
+
+ return url;
+ }
+ }
+
+ if (url == null) {
+
+ url = ClassLoaders.class.getResource(resourceName);
+
+ }else{
+
+ return url;
+ }
+
+ if (url == null) {
+
+ url = ClassLoaders.class.getClassLoader().getResource(resourceName);
+
+ }else{
+
+ return url;
+ }
+
+ if (url == null) {
+
+ url = Thread.currentThread().getContextClassLoader().getResource(
+ resourceName);
+ }
+
+ return url;
+ }
+
+ /**
+ * Carrega um recurso existente no classpath sob a forma de stream.
+ *
+ * @param resourceName
+ * - O nome do resource a ser carregado
+ * @return Stream aberto para o recurso (resource).
+ */
+ public static InputStream getResourceAsStream(String resourceName) {
+
+ return getResourceAsStream(resourceName, null);
+ }
+
+ /**
+ * Carrega um recurso existente no classpath sob a forma de stream com ou
+ * sem uma classe informada.
+ *
+ * @param resourceName
+ * - O nome do resource a ser carregado
+ * @param callingClass
+ * - A classe do objeto chamador ou outro.
+ * @return Stream aberto para o recurso (resource).
+ */
+ public static InputStream getResourceAsStream(String resourceName,
+ Class> callingClass) {
+
+ try {
+
+ return getResource(resourceName, callingClass).openStream();
+
+ } catch (IOException e) {
+
+ return Exceptions.throwIllegalStateException(e);
+ }
+ }
+
+}
diff --git a/src/main/java/org/jrimum/utilix/Collections.java b/src/main/java/org/jrimum/utilix/Collections.java
new file mode 100644
index 0000000..4d46883
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/Collections.java
@@ -0,0 +1,512 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 21:30:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 21:30:00
+ *
+ */
+
+package org.jrimum.utilix;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Classe utilitária para validações de coleções em geral, com e sem exceções.
+ *
+ *
+ * Fornece métodos booleanos e métodos que verificam se uma coleção está de
+ * acordo com o desejado e, caso não estejam, lançam exceção.
+ *
+ *
+ * @author Gilmar P.S.L.
+ * @author Rômulo Augusto
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public final class Collections {
+
+ /**
+ * Utility class pattern: classe não instanciável
+ *
+ * @throws IllegalStateException
+ * Caso haja alguma tentativa de utilização deste construtor.
+ */
+ private Collections() {
+
+ Exceptions.throwIllegalStateException("Instanciação não permitida!");
+ }
+
+ /**
+ * Verifica se a Collection passada por parâmetro é
+ * null ou não possui elementos e lança
+ * exceção caso não preencha estes requisitos.
+ *
+ * @param collection
+ * - Instância de Collection analisada.
+ *
+ * @throws IllegalArgumentException - Caso a coleção não
+ * seja null e possua elementos.
+ *
+ * @see #checkEmpty(Collection, String)
+ * @see #isEmpty(Collection)
+ * @see #isNotEmpty(Collection)
+ *
+ * @since 0.2
+ */
+ public static void checkEmpty(Collection> collection) {
+
+ checkEmpty(collection, "Collection não nulo e com elementos! Valor ["
+ + collection + "].");
+ }
+
+ /**
+ * Verifica se a Collection passado por parâmetro é
+ * null ou não possui elementos e lança
+ * exceção, com a mensagem informada, caso não preencha estes requisitos.
+ *
+ * @param collection
+ * - Instância de Collection analisada.
+ * @param message
+ * - Mensagem utilizada na exceção.
+ *
+ * @throws IllegalArgumentException - Caso a coleção não
+ * seja null e possua elementos.
+ *
+ * @see #isEmpty(Collection)
+ * @see #isNotEmpty(Collection)
+ *
+ * @since 0.2
+ */
+ public static void checkEmpty(Collection> collection, String message) {
+
+ if (hasElement(collection)) {
+
+ Exceptions.throwIllegalArgumentException(message);
+ }
+ }
+
+ /**
+ * Verifica se a Collection passada por parâmetro
+ * não é null e possui elementos e lança
+ * exceção caso não preencha estes requisitos.
+ *
+ * @param collection
+ * - Instância de Collection analisada.
+ *
+ * @throws IllegalArgumentException
+ * - Caso a coleção seja null ou a coleção
+ * não possua elementos.
+ *
+ * @see #checkNotEmpty(Collection, String)
+ * @see #isEmpty(Collection)
+ * @see #isNotEmpty(Collection)
+ *
+ * @since 0.2
+ */
+ public static void checkNotEmpty(Collection> collection) {
+
+ checkNotEmpty(collection, "Objeto nulo!", "Collection sem elementos!");
+ }
+
+ /**
+ * Verifica se a Collection passada por parâmetro
+ * não é null e possui elementos e lança
+ * exceção, com a mensagem informada, caso não preencha estes requisitos.
+ *
+ * @param collection
+ * - Instância de Collection analisada.
+ * @param message
+ * - Mensagem utiliada na exceção.
+ *
+ * @throws IllegalArgumentException
+ * - Caso a coleção seja null ou a coleção
+ * não possua elementos.
+ *
+ * @see #isEmpty(Collection)
+ * @see #isNotEmpty(Collection)
+ *
+ * @since 0.2
+ */
+ public static void checkNotEmpty(Collection> collection, String message) {
+
+ checkNotEmpty(collection, message, message);
+ }
+
+ /**
+ * Verifica se o Map passado por parâmetro é null
+ * ou não possui elementos e lança exceção caso não
+ * preencha estes requisitos.
+ *
+ * @param map
+ * - Instância de Map analisada.
+ *
+ * @throws IllegalArgumentException - Caso o mapa não seja
+ * null e possua elementos.
+ *
+ * @see #checkEmpty(Map, String)
+ * @see #isEmpty(Map)
+ * @see #isNotEmpty(Map)
+ *
+ * @since 0.2
+ */
+ public static void checkEmpty(Map, ?> map) {
+
+ checkEmpty(map, "Map não nulo e com elementos. Valor [" + map + "]");
+ }
+
+ /**
+ * Verifica se o Map passado por parâmetro é null
+ * ou não possui elementos e lança exceção, com a mensagem
+ * informada, caso não preencha estes requisitos.
+ *
+ * @param map
+ * - Instância de Map analisada.
+ * @param message
+ * - Mensagem utilizada na exceção.
+ *
+ * @throws IllegalArgumentException - Caso o mapa não seja
+ * null e possua elementos.
+ *
+ * @see #isEmpty(Map)
+ * @see #isNotEmpty(Map)
+ *
+ * @since 0.2
+ */
+ public static void checkEmpty(Map, ?> map, String message) {
+
+ if (hasElement(map)) {
+
+ Exceptions.throwIllegalArgumentException(message);
+ }
+ }
+
+ /**
+ * Verifica se o Map passado por parâmetro não
+ * é null e possui elementos e lança exceção caso não preencha
+ * estes requisitos.
+ *
+ * @param map
+ * - Instância de Map analisada.
+ *
+ * @throws IllegalArgumentException
+ * - Caso o mapa seja null ou o mapa
+ * não possua elementos.
+ *
+ * @see #checkNotEmpty(Map, String)
+ * @see #isEmpty(Map)
+ * @see #isNotEmpty(Map)
+ *
+ * @since 0.2
+ */
+ public static void checkNotEmpty(Map, ?> map) {
+
+ checkNotEmpty(map, "Objeto nulo", "Map sem elementos");
+ }
+
+ /**
+ * Verifica se o Map passado por parâmetro não
+ * é null e possui elementos e lança exceção, com a mensagem
+ * informada, caso não preencha estes requisitos.
+ *
+ * @param map
+ * - Instância de Map analisada.
+ * @param message
+ * - Mensagem utiliada na exceção.
+ *
+ * @throws IllegalArgumentException
+ * - Caso o mapa seja null ou o mapa
+ * não possua elementos.
+ *
+ * @see #isEmpty(Map)
+ * @see #isNotEmpty(Map)
+ *
+ * @since 0.2
+ */
+ public static void checkNotEmpty(Map, ?> map, String message) {
+
+ checkNotEmpty(map, message, message);
+ }
+
+ /**
+ * Verifica se a Collection passada por parâmetro é
+ * null ou não possui elementos.
+ *
+ * @param collection
+ * - Instância de Collection analisada.
+ * @return !hasElement(collection)
+ *
+ * @since 0.2
+ */
+ public static boolean isEmpty(Collection> collection) {
+
+ return !hasElement(collection);
+ }
+
+ /**
+ * Verifica se a Collection passada por parâmetro
+ * não é null e possui elementos.
+ *
+ * @param collection
+ * - Instância de Collection analisada.
+ * @return hasElement(collection)
+ *
+ * @see #isEmpty(Collection)
+ *
+ * @since 0.2
+ */
+ public static boolean isNotEmpty(Collection> collection) {
+
+ return hasElement(collection);
+ }
+
+ /**
+ * Verifica se o Map passado por parâmetro é null
+ * ou não possui elementos.
+ *
+ * @param map
+ * - Instância de Map analisada.
+ * @return !hasElement(map)
+ *
+ * @since 0.2
+ */
+ public static boolean isEmpty(Map, ?> map) {
+
+ return !hasElement(map);
+ }
+
+ /**
+ * Verifica se o Map passado por parâmetro não
+ * é null e possui elementos.
+ *
+ * @param map
+ * - Instância de Map analisada.
+ * @return hasElement(map)
+ *
+ * @see #isEmpty(Map)
+ *
+ * @since 0.2
+ */
+ public static boolean isNotEmpty(Map, ?> map) {
+
+ return hasElement(map);
+ }
+
+ /**
+ * Indica se pelo menos uma coleção tem algum elemento sem gerar NPE.
+ *
+ * @param cols
+ * - Coleções para teste.
+ *
+ * @return indicativo
+ */
+ public static boolean hasElement(Collection> ... cols) {
+
+ if(Arrays.hasElement(cols)){
+
+ for(Collection> c : cols){
+ if(hasElement(c)){
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Indica se pelo menos um mapa tem algum elemento sem gerar NPE.
+ *
+ * @param maps
+ * - Mapas para teste.
+ *
+ * @return indicativo
+ */
+ public static boolean hasElement(Map, ?> ... maps) {
+
+ if(Arrays.hasElement(maps)){
+
+ for(Map, ?> m : maps){
+ if(hasElement(m)){
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Indica se uma dada coleção tem elementos sem gerar NPE.
+ *
+ * Resposta direta para o seguinte código:
+ * (c != null && !c.isEmpty()).
+ *
+ *
+ * @param c
+ * - A coleção a ser testada.
+ *
+ * @return (c != null && !c.isEmpty())
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(Collection> c) {
+
+ return (c != null && !c.isEmpty());
+ }
+
+ /**
+ * Indica se um dado mapa tem elementos sem gerar NPE.
+ *
+ * Resposta direata para o seguinte código:
+ * (m != null && !m.isEmpty()).
+ *
+ *
+ * @param m
+ * - O mapa a ser testado.
+ *
+ * @return (m != null && !m.isEmpty())
+ *
+ * @since 0.2
+ */
+ public static boolean hasElement(Map, ?> m) {
+
+ return (m != null && !m.isEmpty());
+ }
+
+ /**
+ * Retorna a quantidade de elementos de uma dada coleção sem gerar NPE.
+ *
+ * Resposta direata para o seguinte código:
+ * (c != null ? c.size() : 0).
+ *
+ *
+ * @param c
+ * - Coleção com ou sem elementos.
+ *
+ * @return (c != null ? c.size() : 0)
+ */
+ public static int size(Collection> c) {
+
+ return (c != null ? c.size() : 0);
+ }
+
+ /**
+ * Retorna a quantidade de elementos de um dado mapa sem gerar NPE.
+ *
+ * Resposta direata para o seguinte código:
+ * (m != null ? m.size() : 0).
+ *
+ *
+ * @param m
+ * - Mapa com ou sem elementos.
+ *
+ * @return (m != null ? m.size() : 0)
+ */
+ public static int size(Map, ?> m) {
+
+ return (m != null ? m.size() : 0);
+ }
+
+ /**
+ * Verifica se o coleção passado por parâmetro não é
+ * null ou se é vazio.
+ *
+ * Caso o objeto seja null, lança
+ * NullPointerException com a mensagem informada no parâmetro
+ * messageNullPointer (primeiro parâmetro String). Caso o
+ * objeto não seja null e não possua elementos, lança
+ * IllegalArgumentException com a mensagem informada no
+ * parâmetro messageIllegalArgument (segundo parâmetro String).
+ *
+ *
+ * @param collection
+ * - Objeto analisado.
+ * @param messageNullPointer
+ * - Mensagem utiliada na exceção
+ * IllegalArgumentException.
+ * @param messageIllegalArgument
+ * - Mensagem utiliada na exceção
+ * IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException
+ *
+ * @since 0.2
+ */
+ public static void checkNotEmpty(Collection> collection,
+ String messageNullPointer, String messageIllegalArgument) {
+
+ if (collection == null) {
+
+ Exceptions.throwIllegalArgumentException(messageNullPointer);
+ }
+
+ if (collection.isEmpty()) {
+
+ Exceptions.throwIllegalArgumentException(messageIllegalArgument);
+ }
+ }
+
+ /**
+ * Verifica se o mapa passado por parâmetro não é
+ * null ou se é vazio.
+ *
+ * Caso o objeto seja null, lança
+ * NullPointerException com a mensagem informada no parâmetro
+ * messageNullPointer (primeiro parâmetro String). Caso o
+ * objeto não seja null e não possua elementos, lança
+ * IllegalArgumentException com a mensagem informada no
+ * parâmetro messageIllegalArgument (segundo parâmetro String).
+ *
+ *
+ * @param map
+ * - Objeto analisado.
+ * @param messageNullPointer
+ * - Mensagem utiliada na exceção
+ * IllegalArgumentException.
+ * @param messageIllegalArgument
+ * - Mensagem utiliada na exceção
+ * IllegalArgumentException.
+ *
+ * @throws IllegalArgumentException
+ *
+ * @since 0.2
+ */
+ public static void checkNotEmpty(Map, ?> map, String messageNullPointer,
+ String messageIllegalArgument) {
+
+ if (map == null) {
+
+ Exceptions.throwIllegalArgumentException(messageNullPointer);
+ }
+
+ if (map.isEmpty()) {
+
+ Exceptions.throwIllegalArgumentException(messageIllegalArgument);
+ }
+ }
+
+}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/DateUtil.java b/src/main/java/org/jrimum/utilix/Dates.java
similarity index 50%
rename from src/br/com/nordestefomento/jrimum/utilix/DateUtil.java
rename to src/main/java/org/jrimum/utilix/Dates.java
index fcd8880..114198f 100644
--- a/src/br/com/nordestefomento/jrimum/utilix/DateUtil.java
+++ b/src/main/java/org/jrimum/utilix/Dates.java
@@ -27,9 +27,9 @@
*
*/
-package br.com.nordestefomento.jrimum.utilix;
+package org.jrimum.utilix;
-import static br.com.nordestefomento.jrimum.utilix.ObjectUtil.isNotNull;
+import static org.jrimum.utilix.Objects.isNotNull;
import java.text.DateFormat;
import java.text.ParseException;
@@ -39,190 +39,215 @@
import org.apache.commons.lang.time.DateUtils;
-
/**
- *
- * Esta classe tem a responsabilidade de prover serviços utilitários
- * relacionados a manipulação de Objetos Date, Calendar, GregorianCalendar.
- *
- *
+ *
+ * Serviços utilitários relacionados a manipulação de Objetos
+ * Date, Calendar, GregorianCalendar.
+ *
*
* @author Gilmar P.S.L
- * @author Misael Barreto
- * @author Rômulo Augusto
- * @author Nordeste Fomento Mercantil
+ * @author Misael Barreto
+ * @author Rômulo Augusto
+ * @author Nordeste Fomento
+ * Mercantil
*
* @since 0.2
*
* @version 0.2
*/
-public class DateUtil {
-
- /**
- *
- */
- private static final long serialVersionUID = 4339951860440604914L;
+public final class Dates {
/**
- * Formatador de datas no padrão dd/MM/yyyy.
+ *
+ * Representa uma data inexistente, pode ser usada em casos que não se pode
+ * usar null [ é obtida da seguinte forma:
+ * Calendar.set(1, 0, 1) ]
+ *
*/
- public static final DateFormat FORMAT_DD_MM_YYYY = new SimpleDateFormat("dd/MM/yyyy");
+ private static final Date DATE_NULL;
+
+ static {
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(1, 0, 1);
+ calendar.setLenient(false);
+ DATE_NULL = DateUtils.truncate(calendar.getTime(), Calendar.YEAR);
+ }
/**
- * Formatador de datas no padrão ddMMyy.
+ * Utility class pattern: classe não instanciável
+ *
+ * @throws IllegalStateException
+ * Caso haja alguma tentativa de utilização deste construtor.
*/
- public static final DateFormat FORMAT_DDMMYY = new SimpleDateFormat("ddMMyy");
-
+ private Dates() {
+
+ Exceptions.throwIllegalStateException("Instanciação não permitida!");
+ }
+
/**
- * Formatador de datas no padrão yyMMdd.
+ *
+ * Retorna uma data inexistente, pode ser usada em casos que não se pode
+ * usar null [ é obtida da seguinte forma:
+ * Calendar.set(1, 0, 1) ]
+ *
+ *
+ * @return data invalida - 01/01/0001
*/
- public static final DateFormat FORMAT_YYMMDD = new SimpleDateFormat("yyMMdd");
-
+ public static Date invalidDate(){
+
+ return (Date) DATE_NULL.clone();
+ }
+
/**
- * Representa uma data inexistente. Usada em casos que não se pode usar
- * null.
- *
- * É obtida da seguinte forma: new GregorianCalendar(1, 0, 1).getTime()
+ *
+ * Compara uma dada data qualquer com a data invalida 01/01/0001.
+ *
+ *
+ * @param date - Data qualquer
+ *
+ * @return igualdade - Se igual a data inválida
*/
- public static final Date DATE_NULL;
-
- static {
+ public static boolean equalsInvalidDate(Date date){
- Calendar calendar = Calendar.getInstance();
- calendar.set(1, 0, 1);
- calendar.setLenient(false);
- DATE_NULL = DateUtils.truncate(calendar.getTime(), Calendar.YEAR);
+ if(date == null){
+
+ return false;
+
+ }else{
+
+ return (DATE_NULL.compareTo(date) == 0);
+ }
}
/**
*
- * Converte um objeto String em um objeto java.util.Date
- * no formato de data padrão brasileiro: dd/MM/yyyy.
- *
- *
- * Utiliza a sobrecarca parse(String dateAsString, DateFormat dateFormat) para
- * realizar a conversão.
+ * Calcula a diferença de dias entre duas datas. O resultado é modular, ou
+ * seja, maior ou igual a zero, logo a data final não precisa ser
+ * necessariamente maior que a data inicial.
*
*
- * @param dateAsString - um valor de data em forma de String.
- * @return Objeto java.util.Date convertido a partir do objeto String
+ * @param dataInicial
+ * - data inicial do intervalo.
+ * @param dataFinal
+ * - data final do intervalo.
+ * @return número(módulo) de dias entre as datas.
*
- * @throws IllegalArgumentException caso o objeto String não seja um valor válido
- * de data suportado pelo formato.
+ * @throws IllegalArgumentException
+ * Caso pelo menos uma das duas datas seja null.
+ * @since 0.2
*/
- public static Date parse(String dateAsString) {
+ public static long calculeDiferencaEmDias(final Date dataInicial, final Date dataFinal) {
+
+ long fator = 0;
- return parse(dateAsString, FORMAT_DD_MM_YYYY);
+ Date dataInicialTruncada, dataFinalTruncada;
+
+ if (isNotNull(dataInicial) && isNotNull(dataFinal)) {
+
+ dataInicialTruncada = DateUtils.truncate(dataInicial, Calendar.DATE);
+ dataFinalTruncada = DateUtils.truncate(dataFinal, Calendar.DATE);
+
+ fator = ((dataFinalTruncada.getTime() - dataInicialTruncada.getTime()) / DateUtils.MILLIS_PER_DAY);
+
+ if (fator < 0) {
+ fator *= -1;
+ }
+
+ } else {
+
+ Exceptions.throwIllegalArgumentException("A data inicial [" + dataInicial
+ + "] e a data final [" + dataFinal + "] "
+ + "não podem ter valor 'null'.");
+ }
+
+ return fator;
}
-
+
/**
*
- * Converte um objeto String em um objeto java.util.Date
- * a partir do formato de data especificado.
+ * Converte um objeto String em um objeto
+ * java.util.Date a partir do formato de data especificado.
*
- *
- * Utiliza a sobrecarca parse(String dateAsString, DateFormat dateFormat) para
+ *
+ * Utiliza a sobrecarca
+ * parse(String dateAsString, String dateFormat) para
* realizar a conversão.
*
*
- * @param dateAsString - um valor de data em forma de String.
- * @param dateFormat - formato de data
- * @return Objeto java.util.Date convertido a partir do objeto String
+ * @param dateAsString
+ * - um valor de data em forma de String.
+ * @param dateFormat
+ * - formato de data em forma de String.
+ * @return Objeto java.util.Date convertido a partir do objeto
+ * String
*
- * @throws IllegalArgumentException caso o objeto String não seja um valor válido
- * de data suportado pelo formato.
+ * @throws IllegalArgumentException
+ * caso o objeto String não seja um valor válido de
+ * data suportado pelo formato.
+ * @since 0.2
*/
public static Date parse(String dateAsString, String dateFormat) {
-
+
if (dateFormat == null) {
throw new NullPointerException("O formato da data não pode ter valor [null].");
}
-
+
return parse(dateAsString, new SimpleDateFormat(dateFormat));
}
-
+
/**
- * Converte um objeto String em um objeto java.util.Date
- * através do objeto java.text.DateFormat especificado.
+ *
+ * Converte um objeto String em um objeto
+ * java.util.Date através do objeto
+ * java.text.DateFormat especificado.
+ *
*
- * @param dateAsString - um valor de data em forma de String.
- * @param dateFormat - formatador para objetos java.util.Date.
- * @return Objeto java.util.Date convertido a partir do objeto String
+ * @param dateAsString
+ * - um valor de data em forma de String.
+ * @param dateFormat
+ * - formatador para objetos java.util.Date.
+ * @return Objeto java.util.Date convertido a partir do objeto
+ * String
*
- * @throws IllegalArgumentException caso o objeto String não seja um valor válido
- * de data suportado pelo formatador.
+ * @throws IllegalArgumentException
+ * caso o objeto String não seja um valor válido de
+ * data suportado pelo formatador.
+ * @since 0.2
*/
public static Date parse(String dateAsString, DateFormat dateFormat) {
-
+
Date date = null;
-
+
if (dateAsString == null) {
throw new NullPointerException("A String a ser convertida não pode ter valor [null].");
}
-
+
if (dateFormat == null) {
throw new NullPointerException("O formatador não pode ter valor [null].");
}
-
+
try {
-
+
date = dateFormat.parse(dateAsString);
-
+
} catch (ParseException e) {
-
- String msg = "A String [" + dateAsString + "] deve ser uma data válida no formato";
+
+ String msg = "A String [" + dateAsString
+ + "] deve ser uma data válida no formato";
if (dateFormat instanceof SimpleDateFormat) {
SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
msg += " [" + sdf.toPattern() + "].";
-
+
} else {
msg += " especificado.";
}
-
+
IllegalArgumentException iae = new IllegalArgumentException(msg);
iae.initCause(e);
throw iae;
}
-
+
return date;
}
-
- /**
- *
- * Calcula a diferença de dias entre duas datas. O resultado é modular,
- * ou seja, maior ou igual a zero, logo a data final não precisa ser
- * necessariamente maior que a data inicial.
- *
- *
- * @param dataInicial - data inicial do intervalo.
- * @param dataFinal - data final do intervalo.
- * @return número(módulo) de dias entre as datas.
- *
- * @throws IllegalArgumentException Caso pelo menos uma das duas datas seja null.
- */
- public static long calculeDiferencaEmDias(final Date dataInicial, final Date dataFinal) {
-
- long fator = 0;
- Date dataInicialTruncada, dataFinalTruncada;
-
-
- if (isNotNull(dataInicial) && isNotNull(dataFinal)) {
-
- dataInicialTruncada = DateUtils.truncate(dataInicial, Calendar.DATE);
- dataFinalTruncada = DateUtils.truncate(dataFinal, Calendar.DATE);
-
- fator = ((dataFinalTruncada.getTime() - dataInicialTruncada.getTime()) / DateUtils.MILLIS_PER_DAY);
-
- if (fator < 0) {
- fator *= -1;
- }
- }
- else {
- throw new IllegalArgumentException("A data inicial [" + dataInicial + "] e a data final [" + dataFinal + "] " +
- "não podem ter valor 'null'.");
- }
-
- return fator;
- }
-
}
diff --git a/src/main/java/org/jrimum/utilix/Exceptions.java b/src/main/java/org/jrimum/utilix/Exceptions.java
new file mode 100644
index 0000000..0bf408f
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/Exceptions.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2011 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: 15/05/2011 - 17:54:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2011 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.
+ *
+ * Created at: 15/05/2011 - 17:54:00
+ *
+ */
+
+package org.jrimum.utilix;
+
+/**
+ * Classe utilitária para lançar exceções de modo ecapsulado.
+ *
+ * @author Gilmar P.S.L.
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public class Exceptions {
+
+ /**
+ * Utility class pattern: classe não instanciável
+ *
+ * @throws IllegalStateException
+ * Caso haja alguma tentativa de utilização deste construtor.
+ */
+ private Exceptions() {
+
+ throwIllegalStateException("Instanciação não permitida!");
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalArgumentException}.
+ *
+ * @param
+ * Qualquer tipo.
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalArgumentException() {
+
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalArgumentException}.
+ *
+ * @param
+ * Qualquer tipo.
+ * @param message
+ * Mensagem usada na exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalArgumentException(String message) {
+
+ throw new IllegalArgumentException(message);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalArgumentException}.
+ *
+ * @param
+ * Qualquer tipo.
+ * @param cause
+ * Causa da exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalArgumentException(Throwable cause) {
+
+ throw new IllegalArgumentException(cause);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalArgumentException}.
+ *
+ * @param
+ * Qualquer tipo.
+ *
+ * @param message
+ * Mensagem usada na exceção
+ * @param cause
+ * Causa da exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalArgumentException(String message,
+ Throwable cause) {
+
+ throw new IllegalArgumentException(message, cause);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalStateException}.
+ *
+ * @param
+ * Qualquer tipo.
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalStateException() {
+
+ throw new IllegalStateException();
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalStateException}.
+ *
+ * @param
+ * Qualquer tipo.
+ * @param message
+ * Mensagem usada na exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalStateException(String message) {
+
+ throw new IllegalStateException(message);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalStateException}.
+ *
+ * @param
+ * Qualquer tipo.
+ * @param cause
+ * Causa da exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalStateException(Throwable cause) {
+
+ throw new IllegalStateException(cause);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain IllegalStateException}.
+ *
+ * @param
+ * Qualquer tipo.
+ *
+ * @param message
+ * Mensagem usada na exceção
+ * @param cause
+ * Causa da exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwIllegalStateException(String message,
+ Throwable cause) {
+
+ throw new IllegalStateException(message, cause);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain UnsupportedOperationException}.
+ *
+ * @param
+ * Qualquer tipo.
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwUnsupportedOperationException() {
+
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain UnsupportedOperationException}.
+ *
+ * @param
+ * Qualquer tipo.
+ * @param message
+ * Mensagem usada na exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwUnsupportedOperationException(String message) {
+
+ throw new UnsupportedOperationException(message);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain UnsupportedOperationException}.
+ *
+ * @param
+ * Qualquer tipo.
+ * @param cause
+ * Causa da exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwUnsupportedOperationException(Throwable cause) {
+
+ throw new UnsupportedOperationException(cause);
+ }
+
+ /**
+ * Lança imediatamente uma {@linkplain UnsupportedOperationException}.
+ *
+ * @param
+ * Qualquer tipo.
+ *
+ * @param message
+ * Mensagem usada na exceção
+ * @param cause
+ * Causa da exceção
+ *
+ * @return Não retorna nada, criado apenas para satisfazer alguma condição
+ * de retorno.
+ */
+ public static T throwUnsupportedOperationException(String message,
+ Throwable cause) {
+
+ throw new UnsupportedOperationException(message, cause);
+ }
+}
diff --git a/test/br/com/nordestefomento/jrimum/utilix/TestSuiteUtilix.java b/src/main/java/org/jrimum/utilix/Locales.java
similarity index 64%
rename from test/br/com/nordestefomento/jrimum/utilix/TestSuiteUtilix.java
rename to src/main/java/org/jrimum/utilix/Locales.java
index b7f59ec..cc37960 100644
--- a/test/br/com/nordestefomento/jrimum/utilix/TestSuiteUtilix.java
+++ b/src/main/java/org/jrimum/utilix/Locales.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 JRimum Project
+ * Copyright 2010 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
@@ -9,11 +9,11 @@
* 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 - 19:10:51
+ * Created at: 01/08/2010 - 21:30:00
*
* ================================================================================
*
- * Direitos autorais 2008 JRimum Project
+ * Direitos autorais 2010 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
@@ -23,45 +23,42 @@
* 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 - 19:10:51
+ * Criado em: 01/08/2010 - 21:30:00
*
*/
-package br.com.nordestefomento.jrimum.utilix;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
+package org.jrimum.utilix;
/**
- *
*
- * Classe responsável pela execução do conjunto de testes do projeto Utilix
+ * Locales não disponíveis em java.util.Locale.
*
*
- *
* @author Gilmar P.S.L.
*
* @since 0.2
*
* @version 0.2
*/
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses
-(
- {
- TestField.class,
- TestFiller.class,
- TestDateUtil.class,
- TestMonetaryId.class,
- TestPDFUtil.class,
- TestStringUtil.class
- }
-)
-public class TestSuiteUtilix {
- /*
- * The class remains completely empty, being used only as a holder for the
- * above annotations
+public final class Locales {
+
+ /**
+ *
+ * Localização pt-BR.
+ *
+ */
+ public static final java.util.Locale BRASIL = new java.util.Locale("pt", "BR");
+
+ /**
+ *
+ * Utility class pattern: classe não instanciável
+ *
+ *
+ * @throws IllegalStateException
+ * Caso haja alguma tentativa de utilização deste construtor.
*/
+ private Locales() {
+
+ Exceptions.throwIllegalStateException("Instanciação não permitida!");
+ }
}
diff --git a/src/main/java/org/jrimum/utilix/Objects.java b/src/main/java/org/jrimum/utilix/Objects.java
new file mode 100644
index 0000000..6437909
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/Objects.java
@@ -0,0 +1,362 @@
+/*
+ * 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:02:40
+ *
+ * ================================================================================
+ *
+ * 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:02:40
+ *
+ */
+
+package org.jrimum.utilix;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+/**
+ * Classe utilitária para validações de objetos em geral, como verificações de
+ * objetos nulos, com e sem exceções.
+ *
+ *
+ * Fornece métodos booleanos e métodos que verificam se o valor do objeto está
+ * de acordo com o desejado e, caso não estejam, lançam exceção.
+ *
+ *
+ * @author Gilmar P.S.L.
+ * @author Rômulo Augusto
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public final class Objects {
+
+ /**
+ * Utility class pattern: classe não instanciável
+ *
+ * @throws IllegalStateException
+ * Caso haja alguma tentativa de utilização deste construtor.
+ */
+ private Objects() {
+
+ Exceptions.throwIllegalStateException("Instanciação não permitida!");
+ }
+
+ /**
+ * Verifica se o objeto passado por parâmetro é {@code null}.
+ *
+ * @param object
+ * - Objeto analisado
+ *
+ * @return (object == null)
+ *
+ * @since 0.2
+ */
+ public static boolean isNull(Object object) {
+
+ return (object == null);
+ }
+
+ /**
+ * Verifica se o objeto passado por parâmetro não é
+ * {@code null}.
+ *
+ * É o mesmo que usar o método {@code isNull} da forma
+ * {@code !isNull(obj)}, porém de forma mais legível.
+ *
+ *
+ * @param object
+ * - Objeto analisado
+ *
+ * @return (object != null)
+ *
+ * @see #isNull(Object)
+ *
+ * @since 0.2
+ */
+ public static boolean isNotNull(Object object) {
+
+ return (object != null);
+ }
+
+ /**
+ * Verifica se existe uma referência ao objeto dado.
+ *
+ * @param object
+ * - Objeto analisado
+ *
+ * @return (object != null);
+ *
+ * @see #isNotNull(Object)
+ *
+ * @since 0.2
+ */
+ public static boolean exists(Object object) {
+
+ return (object != null);
+ }
+
+ /**
+ * Verifica a verdade de uma expressão e lança uma
+ * {@code IllegalArgumentException}, caso a expressão seja
+ * false.
+ *
+ * @param expression
+ * - Qualquer expressão booleana
+ * @throws IllegalArgumentException
+ * se {@code expression == false}
+ *
+ * @since 0.2
+ */
+ public static void checkArgument(boolean expression) {
+
+ if (!expression) {
+ Exceptions.throwIllegalArgumentException();
+ }
+ }
+
+ /**
+ * Verifica a verdade de uma expressão e lança uma
+ * {@code IllegalArgumentException}, com a mensagem iformada, caso a
+ * expressão seja false.
+ *
+ * @param expression
+ * - Qualquer expressão booleana
+ * @param message
+ * - Mensagem utilizada na exceção
+ * @throws IllegalArgumentException
+ * se {@code expression == false}
+ *
+ * @since 0.2
+ */
+ public static void checkArgument(boolean expression, String message) {
+
+ if (!expression) {
+ Exceptions.throwIllegalArgumentException(message);
+ }
+ }
+
+ /**
+ * Verifica a verdade de uma expressão e lança uma
+ * {@code IllegalStateException}, caso a expressão seja
+ * false.
+ *
+ * @param expression
+ * - Qualquer expressão booleana
+ * @throws IllegalStateException
+ * se {@code expression == false}
+ *
+ * @since 0.2
+ */
+ public static void checkState(boolean expression) {
+
+ if (!expression) {
+ Exceptions.throwIllegalStateException();
+ }
+ }
+
+ /**
+ * Verifica a verdade de uma expressão e lança uma
+ * {@code IllegalStateException}, com a mensagem iformada, caso a
+ * expressão seja false.
+ *
+ * @param expression
+ * - Qualquer expressão booleana
+ * @param message
+ * - Mensagem utilizada na exceção
+ * @throws IllegalStateException
+ * se {@code expression == false}
+ *
+ * @since 0.2
+ */
+ public static void checkState(boolean expression, String message) {
+
+ if (!expression) {
+ Exceptions.throwIllegalStateException(message);
+ }
+ }
+
+ /**
+ * Verifica se o objeto é nulo e lança {@code IllegalArgumentException}
+ * , com a mensagem informada, caso não seja.
+ *
+ * @throws IllegalArgumentException - Caso o objeto não seja
+ * {@code null}.
+ *
+ * @see #isNull(Object)
+ * @see #isNotNull(Object)
+ *
+ * @since 0.2
+ *
+ * @param object
+ * - Objeto analisado
+ * @param message
+ * - Mensagem utilizada na exceção
+ */
+ public static void checkNull(Object object, String message) {
+
+ if (object != null) {
+
+ Exceptions.throwIllegalArgumentException(message);
+ }
+ }
+
+ /**
+ * Verifica se o objeto é nulo e lança {@code IllegalArgumentException}
+ * caso não seja.
+ *
+ * @param object
+ * - Objeto analisado
+ *
+ * @throws IllegalArgumentException - Caso o objeto não seja
+ * {@code null}.
+ *
+ * @see #checkNull(Object, String)
+ * @see #isNull(Object)
+ * @see #isNotNull(Object)
+ *
+ * @since 0.2
+ */
+ public static void checkNull(Object object) {
+
+ checkNull(object, new StringBuilder("Objeto não nulo! Valor [ ")
+ .append(object).append(" ].").toString());
+ }
+
+ /**
+ * Verifica se o objeto não é nulo e lança
+ * {@code IllegalArgumentException}, com a mensagem informada, caso
+ * seja.
+ *
+ * @param object
+ * - Objeto analisado
+ * @param message
+ * - Mensagem utilizada na exceção
+ *
+ * @throws IllegalArgumentException - Caso o objeto seja {@code null}.
+ *
+ * @see #isNull(Object)
+ * @see #isNotNull(Object)
+ *
+ * @since 0.2
+ */
+ public static void checkNotNull(Object object, String message) {
+
+ if (object == null) {
+
+ Exceptions.throwIllegalArgumentException(message);
+ }
+ }
+
+ /**
+ * Verifica se o objeto não é nulo e lança
+ * {@code IllegalArgumentException} caso seja.
+ *
+ * @param object
+ * - Objeto analisado
+ *
+ * @throws IllegalArgumentException - Caso o objeto seja {@code null}.
+ *
+ * @see #checkNotNull(Object, String)
+ * @see #isNull(Object)
+ * @see #isNotNull(Object)
+ *
+ * @since 0.2
+ */
+ public static void checkNotNull(Object object) {
+
+ checkNotNull(object, "Objeto nulo!");
+ }
+
+ /**
+ * Retorna um dado valor padrão quando o determinado objeto for nulo.
+ *
+ *
+ *
+ * @param
+ * tipo do objeto pretendido
+ * @param object
+ * - O {@code objeto} a testar, pode ser {@code null}
+ * @param defaultValue
+ * - O valor padrão retornado, pode ser {@code null}
+ * @return {@code object} - Se não nulo, caso contrário
+ * {@code defaultValue}
+ *
+ * @since 0.2
+ */
+ @SuppressWarnings("unchecked")
+ public static T whenNull(Object object, Object defaultValue) {
+
+ return (T) (object != null ? object : defaultValue);
+ }
+
+ /**
+ * Retorna um dado valor padrão quando o determinado objeto for nulo e outro
+ * valor quando contrário.
+ *
+ *
+ *
+ * @param
+ * tipo do objeto pretendido
+ * @param object
+ * - O {@code objeto} a testar, pode ser {@code null}
+ * @param defaultValue
+ * - O valor padrão retornado, pode ser {@code null}
+ * @param notDefaultValue
+ * - O valor quando {@code object} é nulo, pode ser
+ * {@code null}
+ * @return {@code defaultValue} - Se não nulo, caso contrário
+ * {@code notDefaultValue}
+ *
+ * @since 0.2
+ */
+ @SuppressWarnings("unchecked")
+ public static T whenNull(Object object, Object defaultValue,
+ Object notDefaultValue) {
+
+ return (T) (object == null ? defaultValue : notDefaultValue);
+ }
+
+ /**
+ * Exibe os valores de instância para um objeto JRimum.
+ *
+ * @see org.apache.commons.lang.builder.ToStringBuilder#reflectionToString
+ *
+ * @since 0.2
+ *
+ * @see java.lang.Object#toString()
+ */
+ public static String toString(Object obj) {
+
+ return "JRimumObject: " + ToStringBuilder.reflectionToString(obj);
+ }
+}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/TextStream.java b/src/main/java/org/jrimum/utilix/package-info.java
similarity index 68%
rename from src/br/com/nordestefomento/jrimum/utilix/TextStream.java
rename to src/main/java/org/jrimum/utilix/package-info.java
index d1b618e..667743f 100644
--- a/src/br/com/nordestefomento/jrimum/utilix/TextStream.java
+++ b/src/main/java/org/jrimum/utilix/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 JRimum Project
+ * Copyright 2010 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
@@ -9,11 +9,11 @@
* 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
+ * Created at: 15/08/2010 - 15:37:49
*
* ================================================================================
*
- * Direitos autorais 2008 JRimum Project
+ * Direitos autorais 2010 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
@@ -23,28 +23,13 @@
* 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
+ * Criado em: 15/08/2010 - 15:37:49
*
*/
-
-package br.com.nordestefomento.jrimum.utilix;
-
/**
- *
- * Interface usada para objetos com serviços de leitura e escrita de textos.
- *
+ * Classes utilitárias ou de propósito comum, que são necessárias ao projeto.
*
* @author Gilmar P.S.L
- * @author Misael Barreto
- * @author Rômulo Augusto
- * @author Nordeste Fomento
- * Mercantil
- *
- * @since 0.2
- *
- * @version 0.2
*/
-public interface TextStream extends ReadWriteStream {
-
-}
+package org.jrimum.utilix;
\ No newline at end of file
diff --git a/src/main/java/org/jrimum/utilix/text/DateFormat.java b/src/main/java/org/jrimum/utilix/text/DateFormat.java
new file mode 100644
index 0000000..90470a4
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/text/DateFormat.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 17:31:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 17:31:00
+ *
+ */
+
+package org.jrimum.utilix.text;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.jrimum.utilix.Exceptions;
+
+/**
+ *
+ * Formatadores de data thread-safe. Para uma mesma categoria, os formatadores
+ * atualmente são diferenciados pelos seus separadores ("formato_separador")
+ * exemplos:
+ *
+ * Formatador de datas no padrão "dd/MM/yyyy".
+ *
+ */
+ DDMMYYYY_B("dd/MM/yyyy"),
+
+ /**
+ *
+ * Formatador de datas no padrão "dd-MM-yyyy".
+ *
+ */
+ DDMMYYYY_H("dd-MM-yyyy"),
+
+ /**
+ *
+ * Formatador de datas no padrão "dd_MM_yyyy".
+ *
+ */
+ DDMMYYYY_U("dd_MM_yyyy"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yyMMdd".
+ *
+ */
+ YYMMDD("yyMMdd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yy/MM/dd".
+ *
+ */
+ YYMMDD_B("yy/MM/dd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yy/MM/dd".
+ *
+ */
+ YYMMDD_H("yy-MM-dd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yy_MM_dd".
+ *
+ */
+ YYMMDD_U("yy_MM_dd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yyyyMMdd".
+ *
+ */
+ YYYYMMDD("yyyyMMdd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yyyy/MM/dd".
+ *
+ */
+ YYYYMMDD_B("yyyy/MM/dd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yyyy-MM-dd".
+ *
+ */
+ YYYYMMDD_H("yyyy-MM-dd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "yyyy_MM_dd".
+ *
+ */
+ YYYYMMDD_U("yyyy_MM_dd"),
+
+ /**
+ *
+ * Formatador de datas no padrão "hhmmss".
+ *
+ */
+ HHMMSS("hhmmss"),
+
+ /**
+ *
+ * Formatador de datas no padrão "HHmmss".
+ *
+ */
+ HHMMSS_24("HHmmss"),
+
+ /**
+ *
+ * Formatador de datas no padrão "hh:mm:ss".
+ *
+ */
+ HHMMSS_C("hh:mm:ss"),
+
+ /**
+ *
+ * Formatador de datas no padrão "HH:mm:ss".
+ *
+ */
+ HHMMSS_24C("HH:mm:ss"),
+ ;
+
+ private final ThreadLocalFormat DATE_FORMAT;
+
+ private DateFormat(String format) {
+
+ DATE_FORMAT = new ThreadLocalFormat(format){
+
+ @Override
+ protected SimpleDateFormat initialValue() {
+
+ return new SimpleDateFormat(format);
+ }
+
+ };
+ }
+
+ /**
+ * @see org.jrimum.utilix.text.Format#format(java.lang.Object)
+ */
+ public String format(Date obj) {
+
+ return DATE_FORMAT.get().format(obj);
+ }
+
+ /**
+ * @see org.jrimum.utilix.text.Format#parse(java.lang.String)
+ */
+ public Date parse(String text) {
+
+ try {
+
+ return DATE_FORMAT.get().parse(text);
+
+ } catch (ParseException e) {
+
+ return Exceptions.throwIllegalArgumentException("DateFormat Exception!", e);
+ }
+ }
+
+ /**
+ * @see org.jrimum.utilix.text.Format#copy()
+ */
+ public SimpleDateFormat copy(){
+
+ return (SimpleDateFormat) DATE_FORMAT.get().clone();
+ }
+}
diff --git a/src/main/java/org/jrimum/utilix/text/DecimalFormat.java b/src/main/java/org/jrimum/utilix/text/DecimalFormat.java
new file mode 100644
index 0000000..1e77c52
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/text/DecimalFormat.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 21:30:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 21:30:00
+ *
+ */
+
+package org.jrimum.utilix.text;
+
+import java.text.ParseException;
+
+import org.jrimum.utilix.Exceptions;
+
+/**
+ *
+ * Formatadores thread-safe relacionados a moeda e números decimais.
+ *
+ * Formatador de decimais Float,Double,BigDecimal no padrão de
+ * moeda (Real pt-BR): "R$ #,##0.0". Usado para formatar valores
+ * monetários em real com o prefixo R$, exemplo: R$ 10,0.
+ *
+ * Formatador de decimais Float,Double,BigDecimal no padrão de
+ * moeda (Real pt-BR): "R$ #,##0.00". Usado para formatar valores
+ * monetários em real com o prefixo R$, exemplo: R$ 10,00.
+ *
+ */
+ MONEY_DD_BR("\u00A4 #,##0.00", DecimalFormatSymbols.BRASIL.copy()),
+
+ ;
+
+ private final ThreadLocalLocalizedFormat DECIMAL_FORMAT;
+
+ private DecimalFormat(String format, java.text.DecimalFormatSymbols formatSymbols) {
+
+ DECIMAL_FORMAT = new ThreadLocalLocalizedFormat(format, formatSymbols){
+
+ @Override
+ protected java.text.DecimalFormat initialValue() {
+
+ return new java.text.DecimalFormat(format, formatSymbols);
+ }
+ };
+ }
+
+ /**
+ * @see org.jrimum.utilix.text.Format#format(java.lang.Object)
+ */
+ public String format(Number obj) {
+
+ return DECIMAL_FORMAT.get().format(obj);
+ }
+
+ /**
+ * @see org.jrimum.utilix.text.Format#parse(java.lang.String)
+ */
+ public Number parse(String text) {
+
+ try {
+
+ return DECIMAL_FORMAT.get().parse(text);
+
+ } catch (ParseException e) {
+
+ return Exceptions.throwIllegalArgumentException("DecimalFormat Exception!", e);
+ }
+ }
+
+ /**
+ * @see org.jrimum.utilix.text.Format#copy()
+ */
+ public java.text.DecimalFormat copy(){
+
+ return (java.text.DecimalFormat) DECIMAL_FORMAT.get().clone();
+ }
+}
diff --git a/src/main/java/org/jrimum/utilix/text/DecimalFormatSymbols.java b/src/main/java/org/jrimum/utilix/text/DecimalFormatSymbols.java
new file mode 100644
index 0000000..4cf86dc
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/text/DecimalFormatSymbols.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 21:30:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 21:30:00
+ *
+ */
+
+package org.jrimum.utilix.text;
+
+import java.util.Currency;
+
+import org.jrimum.utilix.Locales;
+
+/**
+ *
+ * DecimalFormatSymbols com localização (Processo de localização) inicialmente
+ * do Brasil.
+ *
+ *
+ * @return símbolos - Instância de
+ * java.text.DecimalFormatSymbols estilo pt-BR
+ *
+ * @since 0.2
+ */
+ public java.text.DecimalFormatSymbols copy() {
+
+ return (java.text.DecimalFormatSymbols) DF_SYMBOLS.get().clone();
+ }
+}
diff --git a/src/main/java/org/jrimum/utilix/text/Format.java b/src/main/java/org/jrimum/utilix/text/Format.java
new file mode 100644
index 0000000..7e53c50
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/text/Format.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 17:31:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 17:31:00
+ *
+ */
+
+package org.jrimum.utilix.text;
+
+/**
+ *
+ * Interface usada para objetos formatadores utilizados em leitura e escrita de
+ * textos.
+ *
+ * Transforma uma string formatada em um objeto correspondente.
+ *
+ *
+ * @param text
+ * - Texto a ser analisado e transformado em objeto.
+ * @return objeto - Resultado da transformação da string.
+ */
+ T parse(String text);
+
+ /**
+ *
+ * Devolve uma cópia do formatador utilizado pela instância.
+ *
+ *
+ * @return formatador - Cópia da instância do formatador.
+ */
+ F copy();
+}
diff --git a/src/main/java/org/jrimum/utilix/text/Strings.java b/src/main/java/org/jrimum/utilix/text/Strings.java
new file mode 100644
index 0000000..05bc70c
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/text/Strings.java
@@ -0,0 +1,516 @@
+/*
+ * 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:18:19
+ *
+ * ================================================================================
+ *
+ * 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:18:19
+ *
+ */
+
+package org.jrimum.utilix.text;
+
+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.isNotBlank;
+import static org.apache.commons.lang.StringUtils.isNumeric;
+import static org.apache.commons.lang.StringUtils.leftPad;
+import static org.apache.commons.lang.StringUtils.removeStart;
+import static org.apache.commons.lang.StringUtils.replace;
+import static org.apache.commons.lang.StringUtils.replaceChars;
+import static org.apache.commons.lang.StringUtils.startsWith;
+import static org.jrimum.utilix.Objects.isNotNull;
+
+import org.apache.commons.lang.StringUtils;
+import org.jrimum.utilix.Exceptions;
+import org.jrimum.utilix.Objects;
+
+/**
+ * Esta classe tem a responsabilidade de prover serviços utilitários
+ * relacionados a manipulação de Strings
+ *
+ * @author Gilmar P.S.L
+ * @author Misael Barreto
+ * @author Rômulo Augusto
+ * @author Nordeste Fomento
+ * Mercantil
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public final class Strings {
+
+ public static final String WHITE_SPACE = " ";
+
+ /**
+ * Utility class pattern: classe não instanciável
+ *
+ * @throws AssertionError
+ * caso haja alguma tentativa de utilização deste construtor.
+ */
+ private Strings() {
+
+ Exceptions.throwIllegalStateException("Instanciação não permitida!");
+ }
+
+ /**
+ * Elimina simbolos como:
+ *
+ *
+ *
+ * @param str
+ * @return a string sem zeros inicias ou um único zero.
+ *
+ * @since 0.2
+ */
+
+ public static String removeStartWithZeros(final String str) {
+
+ String withoutZeros = EMPTY;
+ final String zero = "0";
+
+ if (isNotNull(str)) {
+
+ if (startsWith(str, zero)) {
+
+ withoutZeros = removeStart(str, zero);
+
+ while (startsWith(withoutZeros, zero)) {
+ withoutZeros = removeStart(withoutZeros, zero);
+ }
+
+ if (withoutZeros.trim().length() == 0) {
+ withoutZeros = zero;
+ }
+
+ } else {
+ withoutZeros = str;
+ }
+ }
+
+ return withoutZeros;
+ }
+
+ /**
+ * Remove a acentuação do texto, que inclui os acentos:
+ *
+ *
Agudo. ex.: á
+ *
Grave. ex.: à
+ *
Til. ex.: ã
+ *
Trema. ex.: ä
+ *
Circunflexo. ex.: â
+ *
+ * e o Cedilha (ç).
+ *
+ * Os acentos são removidos tanto para letras minúsculas como para letras
+ * maiúsculas.
+ *
+ *
+ * @param value
+ * String com os caracteres a serem removidos.
+ * @return String sem acentuação.
+ * @since 0.2
+ */
+ public static String eliminateAccent(final String value) {
+
+ String modifiedValue = value;
+
+ // Para ç e Ç
+ modifiedValue = replaceChars(modifiedValue, '\u00E7', 'c');
+ modifiedValue = replaceChars(modifiedValue, '\u00C7', 'C');
+
+ // Para à, á, â, ã e ä
+ modifiedValue = replaceChars(modifiedValue, '\u00E0', 'a');
+ modifiedValue = replaceChars(modifiedValue, '\u00E1', 'a');
+ modifiedValue = replaceChars(modifiedValue, '\u00E2', 'a');
+ modifiedValue = replaceChars(modifiedValue, '\u00E3', 'a');
+ modifiedValue = replaceChars(modifiedValue, '\u00E4', 'a');
+
+ // Para è, é, ê e ë
+ modifiedValue = replaceChars(modifiedValue, '\u00E8', 'e');
+ modifiedValue = replaceChars(modifiedValue, '\u00E9', 'e');
+ modifiedValue = replaceChars(modifiedValue, '\u00EA', 'e');
+ modifiedValue = replaceChars(modifiedValue, '\u00EB', 'e');
+
+ // Para ì, í, î e ï
+ modifiedValue = replaceChars(modifiedValue, '\u00EC', 'i');
+ modifiedValue = replaceChars(modifiedValue, '\u00ED', 'i');
+ modifiedValue = replaceChars(modifiedValue, '\u00EE', 'i');
+ modifiedValue = replaceChars(modifiedValue, '\u00EF', 'i');
+
+ // Para ò, ó, ô, õ e ö
+ modifiedValue = replaceChars(modifiedValue, '\u00F2', 'o');
+ modifiedValue = replaceChars(modifiedValue, '\u00F3', 'o');
+ modifiedValue = replaceChars(modifiedValue, '\u00F4', 'o');
+ modifiedValue = replaceChars(modifiedValue, '\u00F5', 'o');
+ modifiedValue = replaceChars(modifiedValue, '\u00F6', 'o');
+
+ // Para ù, ú, û e ü
+ modifiedValue = replaceChars(modifiedValue, '\u00F9', 'u');
+ modifiedValue = replaceChars(modifiedValue, '\u00FA', 'u');
+ modifiedValue = replaceChars(modifiedValue, '\u00FB', 'u');
+ modifiedValue = replaceChars(modifiedValue, '\u00FC', 'u');
+
+ // Para À, Á, Â, Ã e Ä
+ modifiedValue = replaceChars(modifiedValue, '\u00C0', 'A');
+ modifiedValue = replaceChars(modifiedValue, '\u00C1', 'A');
+ modifiedValue = replaceChars(modifiedValue, '\u00C2', 'A');
+ modifiedValue = replaceChars(modifiedValue, '\u00C3', 'A');
+ modifiedValue = replaceChars(modifiedValue, '\u00C4', 'A');
+
+ // Para È, É, Ê e Ë
+ modifiedValue = replaceChars(modifiedValue, '\u00C8', 'E');
+ modifiedValue = replaceChars(modifiedValue, '\u00C9', 'E');
+ modifiedValue = replaceChars(modifiedValue, '\u00CA', 'E');
+ modifiedValue = replaceChars(modifiedValue, '\u00CB', 'E');
+
+ // Para Ì, Í, Î e Ï
+ modifiedValue = replaceChars(modifiedValue, '\u00CC', 'I');
+ modifiedValue = replaceChars(modifiedValue, '\u00CD', 'I');
+ modifiedValue = replaceChars(modifiedValue, '\u00CE', 'I');
+ modifiedValue = replaceChars(modifiedValue, '\u00CF', 'I');
+
+ // Para Ò, Ó, Ô, Õ e Ö
+ modifiedValue = replaceChars(modifiedValue, '\u00D2', 'O');
+ modifiedValue = replaceChars(modifiedValue, '\u00D3', 'O');
+ modifiedValue = replaceChars(modifiedValue, '\u00D4', 'O');
+ modifiedValue = replaceChars(modifiedValue, '\u00D5', 'O');
+ modifiedValue = replaceChars(modifiedValue, '\u00D6', 'O');
+
+ // Para Ù, Ú, Û e Ü
+ modifiedValue = replaceChars(modifiedValue, '\u00D9', 'U');
+ modifiedValue = replaceChars(modifiedValue, '\u00DA', 'U');
+ modifiedValue = replaceChars(modifiedValue, '\u00DB', 'U');
+ modifiedValue = replaceChars(modifiedValue, '\u00DC', 'U');
+
+ return modifiedValue;
+ }
+
+ /**
+ * Verifica se a String passada por parâmetro não é
+ * null e não é numérica, ou seja, se a string não contém
+ * somente dígitos unicode.
+ *
+ * Lança exceção, com a mensagem passada por parâmetro (segundo parâmetro
+ * String), caso não preencha estes requisitos.
+ *
+ *
+ * @param value
+ * - String analisada
+ *
+ * @param message
+ * - Mensagem utiliada na exceção.
+ *
+ * @throws IllegalArgumentException - Caso a string seja null ou
+ * caso a string não seja numérica.
+ *
+ * @since 0.2
+ */
+ public static void checkNotNumeric(String value, String message) {
+
+ checkNotNumeric(value, message, message);
+ }
+
+ /**
+ * Verifica se a String passada por parâmetro não é
+ * null e não é numérica, ou seja, se a string não contém
+ * somente dígitos unicode.
+ *
+ * Lança exceção, com a mensagem passada por parâmetro (segundo parâmetro
+ * String), caso não preencha estes requisitos.
+ *
+ *
+ * @param value
+ * - String analisada
+ *
+ * @throws IllegalArgumentException - Caso a string seja null ou
+ * caso a string não seja numérica.
+ *
+ * @since 0.2
+ */
+ public static void checkNotNumeric(String value) {
+
+ checkNotNumeric(value, "String nula!", format(
+ "Valor inválido. String [\"%s\"] não numérica!", value));
+ }
+
+ /**
+ * Verifica se a String passada por parâmetro não é
+ * null, não é vazia (EMPTY) e não possui apenas
+ * espaços em branco.
+ *
+ * Lança exceção, com a mensagem passada por parâmetro (segundo parâmetro
+ * String), caso não preencha estes requisitos.
+ *
+ *
+ * @param value
+ * - String analisada
+ *
+ * @param message
+ * - Mensagem utiliada na exceção.
+ *
+ * @throws IllegalArgumentException - Caso a string seja null ou
+ * caso a string seja vazia.
+ *
+ * @since 0.2
+ */
+ public static void checkNotBlank(String value, String message) {
+
+ checkNotBlank(value, message, message);
+ }
+
+ /**
+ * Verifica se a String passada por parâmetro não é
+ * null, não é vazia (EMPTY) e não possui apenas
+ * espaços em branco. Lança exceção caso não preencha estes requisitos.
+ *
+ * @param value
+ * - String analisada
+ *
+ * @throws IllegalArgumentException - Caso a string seja null ou
+ * caso a string seja vazia.
+ *
+ * @since 0.2
+ */
+ public static void checkNotBlank(String value) {
+
+ checkNotBlank(
+ value,
+ "String nula!",
+ format(
+ "Valor inválido. String [\"%s\"] vazia ou contendo somente espaços em branco!",
+ value));
+ }
+
+ /**
+ * Retorna uma dado valor padrão quando a string informada for considerada
+ * como blank por {@linkplain StringUtils#isBlank(String)}.
+ *
+ *
+ *
+ * @param str
+ * String a testar e ser usada como valor de retorno se não for
+ * blank, pode ser null
+ * @param defaultValue
+ * - O valor padrão retornado caso a string testada seja blank,
+ * pode ser null
+ * @return String - Se não for blank, caso contrário
+ * defaultValue
+ *
+ * @since 0.2
+ */
+ public static String whenBlank(String str, String defaultValue) {
+
+ return (isNotBlank(str) ? str : defaultValue);
+ }
+
+ /**
+ * Método privado para fins de reutilização de código.
+ *
+ * Verifica se a String passada por parâmetro não é
+ * null e não é numérica, ou seja, se a string não contém
+ * somente dígitos unicode.
+ *
+ *
+ * Lança IllegalArgumentException, com a mensagem definida em
+ * messageNullPointer (segundo parâmetro String), caso o valor
+ * passado seja null
+ *
+ *
+ * Lança IllegalArgumentException, com a mensagem definida em
+ * messageIllegalArgument (terceiro parâmetro String), caso o
+ * valor passado não seja numérico.
+ *
+ *
+ * @param value
+ * - String analisada
+ *
+ * @param messageNullPointer
+ * - Mensagem utiliada na exceção.
+ *
+ * @param messageIllegalArgument
+ * - Mensagem utiliada na exceção.
+ *
+ *
+ * @throws IllegalArgumentException - Caso a string seja null ou
+ * caso a string não seja numérica.
+ *
+ * @since 0.2
+ */
+ private static void checkNotNumeric(String value,
+ String messageNullPointer, String messageIllegalArgument) {
+
+ Objects.checkNotNull(value, messageNullPointer);
+
+ if (!isNumeric(value)) {
+ Exceptions.throwIllegalArgumentException(messageIllegalArgument);
+ }
+ }
+
+ /**
+ * Método privado para fins de reutilização de código.
+ *
+ * Verifica se a String passada por parâmetro não é
+ * null, não é vazia (StringUtils.EMPTY) e não
+ * possui apenas espaços em branco.
+ *
+ *
+ * Lança IllegalArgumentException, com a mensagem definida em
+ * messageNullPointer (segundo parâmetro String), caso o valor
+ * passado seja null
+ *
+ *
+ * Lança IllegalArgumentException, com a mensagem definida em
+ * messageIllegalArgument (terceiro parâmetro String), caso o
+ * valor passado seja vazio.
+ *
+ *
+ * @param value
+ * - String analisada
+ *
+ * @param messageNullPointer
+ * - Mensagem utiliada na exceção.
+ *
+ * @param messageIllegalArgument
+ * - Mensagem utiliada na exceção.
+ *
+ * @throws IllegalArgumentException - Caso a string seja null ou
+ * caso a string seja vazia.
+ *
+ * @since 0.2
+ */
+ private static void checkNotBlank(String value, String messageNullPointer,
+ String messageIllegalArgument) {
+
+ Objects.checkNotNull(value, messageNullPointer);
+
+ if (isBlank(value)) {
+ Exceptions.throwIllegalArgumentException(messageIllegalArgument);
+ }
+ }
+
+ /**
+ * Retorna uma string de tamanho informado {@code length} com o
+ * preenchimento de zeros à esquerda para o número informado.
+ *
+ * @param numberToFill
+ * Número a ser transformado em string com zeros à esquerda
+ * @param length
+ * Tamanho final da string com zeros à esquerda
+ * @return string com zeros a esquerda
+ */
+ public static String fillWithZeroLeft(int numberToFill, int length){
+ return fillWithZeroLeft(String.valueOf(numberToFill), length);
+ }
+
+ /**
+ * Retorna uma string de tamanho informado {@code length} com o
+ * preenchimento de zeros à esquerda para o número informado.
+ *
+ * @param numberToFill
+ * Número a ser transformado em string com zeros à esquerda
+ * @param length
+ * Tamanho final da string com zeros à esquerda
+ * @return string com zeros a esquerda
+ */
+ public static String fillWithZeroLeft(long numberToFill, int length){
+ return fillWithZeroLeft(String.valueOf(numberToFill), length);
+ }
+
+ /**
+ * Retorna uma string de tamanho informado {@code length} com o
+ * preenchimento de zeros à esquerda para a string informada.
+ *
+ * @param stringToFill
+ * String a ser preenchida com zeros à esquerda
+ * @param length
+ * Tamanho final da string com zeros à esquerda
+ * @return string com zeros a esquerda
+ */
+ public static String fillWithZeroLeft(String stringToFill, int length){
+ return leftPad(stringToFill, length, "0");
+ }
+}
diff --git a/src/main/java/org/jrimum/utilix/text/ThreadLocalFormat.java b/src/main/java/org/jrimum/utilix/text/ThreadLocalFormat.java
new file mode 100644
index 0000000..d67e276
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/text/ThreadLocalFormat.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 17:31:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 17:31:00
+ *
+ */
+
+package org.jrimum.utilix.text;
+
+import org.jrimum.utilix.Objects;
+
+/**
+ *
+ * Abstração para o uso de formatadores thread-safe em enumerações.
+ *
+ *
+ * @author Gilmar P.S.L.
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public abstract class ThreadLocalFormat extends ThreadLocal {
+
+ protected final String format;
+
+ protected ThreadLocalFormat(String format) {
+
+ Objects.checkNotNull(format, "INVALID NULL FORMAT!");
+
+ this.format = format;
+ }
+}
diff --git a/src/main/java/org/jrimum/utilix/text/ThreadLocalLocalizedFormat.java b/src/main/java/org/jrimum/utilix/text/ThreadLocalLocalizedFormat.java
new file mode 100644
index 0000000..2009b06
--- /dev/null
+++ b/src/main/java/org/jrimum/utilix/text/ThreadLocalLocalizedFormat.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2010 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: 01/08/2010 - 21:30:00
+ *
+ * ================================================================================
+ *
+ * Direitos autorais 2010 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: 01/08/2010 - 21:30:00
+ *
+ */
+
+package org.jrimum.utilix.text;
+
+import java.util.Locale;
+
+import org.jrimum.utilix.Objects;
+
+/**
+ *
+ * Abstração para o uso de formatadores thread-safe com o uso de "localização"
+ * em enumerações.
+ *
+ *
+ * @author Gilmar P.S.L.
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public abstract class ThreadLocalLocalizedFormat extends ThreadLocalFormat {
+
+ protected final Locale locale;
+ protected final S formatSymbols;
+
+ protected ThreadLocalLocalizedFormat(String format, Locale locale) {
+
+ super(format);
+
+ Objects.checkNotNull(locale, "INVALID NULL LOCALE!");
+
+ this.locale = locale;
+ this.formatSymbols = null;
+ }
+
+ protected ThreadLocalLocalizedFormat(String format, S formatSymbols) {
+
+ super(format);
+
+ Objects.checkNotNull(formatSymbols, "INVALID NULL FORMAT SYMBOLS!");
+
+ this.formatSymbols = formatSymbols;
+ this.locale = null;
+ }
+
+ protected ThreadLocalLocalizedFormat(String format, Locale locale,
+ S formatSymbols) {
+
+ super(format);
+
+ Objects.checkNotNull(locale, "INVALID NULL LOCALE!");
+ Objects.checkNotNull(formatSymbols, "INVALID NULL FORMAT SYMBOLS!");
+
+ this.formatSymbols = formatSymbols;
+ this.locale = locale;
+ }
+}
diff --git a/src/br/com/nordestefomento/jrimum/utilix/ReadWriteStream.java b/src/main/java/org/jrimum/utilix/text/package-info.java
similarity index 67%
rename from src/br/com/nordestefomento/jrimum/utilix/ReadWriteStream.java
rename to src/main/java/org/jrimum/utilix/text/package-info.java
index 1687f6c..69319d5 100644
--- a/src/br/com/nordestefomento/jrimum/utilix/ReadWriteStream.java
+++ b/src/main/java/org/jrimum/utilix/text/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 JRimum Project
+ * Copyright 2010 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
@@ -9,11 +9,11 @@
* 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
+ * Created at: 15/08/2010 - 15:37:49
*
* ================================================================================
*
- * Direitos autorais 2008 JRimum Project
+ * Direitos autorais 2010 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
@@ -23,31 +23,13 @@
* 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
+ * Criado em: 15/08/2010 - 15:37:49
*
*/
-
-package br.com.nordestefomento.jrimum.utilix;
-
-import java.io.Serializable;
-
-public interface ReadWriteStream extends Serializable{
-
-
- /**
- * Escreve o tipo infomado.
- *
- * @return Um valor no mesmo tipo do tipo parametrizado
- */
- public abstract G write();
-
-
- /**
- * Lê o tipo informado.
- *
- * @param g - valor a ser lido
- */
- public abstract void read(G g);
-
-}
+/**
+ * Classes relacionadas a manipulação, extração, composição e formatação de textos.
+ *
+ * @author Gilmar P.S.L
+ */
+package org.jrimum.utilix.text;
\ No newline at end of file
diff --git a/src/test/java/org/jrimum/utilix/TestCollections.java b/src/test/java/org/jrimum/utilix/TestCollections.java
new file mode 100644
index 0000000..a8664af
--- /dev/null
+++ b/src/test/java/org/jrimum/utilix/TestCollections.java
@@ -0,0 +1,230 @@
+/*
+ * 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: 31/07/2010 - 23:04:41
+ */
+
+package org.jrimum.utilix;
+
+import static java.util.Collections.EMPTY_LIST;
+import static java.util.Collections.EMPTY_MAP;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * Teste unitário para a classe utilitária de coleções.
+ *
+ *
+ * @author Gilmar P.S.L.
+ * @author Rômulo Augusto
+ *
+ * @since 0.2
+ *
+ * @version 0.2
+ */
+public class TestCollections {
+
+ private static final Object EMPTY_OBJECT = new Object();
+
+ private static final Map