Revision 40604

View differences:

tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.buildtools/src/main/resources/header.txt
1
gvSIG. Desktop Geographic Information System.
2

  
3
Copyright (C) 2007-2013 gvSIG Association.
4
  
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 3
8
of the License, or (at your option) any later version.
9
  
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14
 
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
18
MA  02110-1301, USA.
19

  
20
For any additional information, do not hesitate to contact us 
21
at info AT gvsig.com, or visit our website www.gvsig.com.
0 22

  
tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.buildtools/src/main/resources/gvsig/checkstyle.xml
1
<?xml version="1.0"?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE module PUBLIC
28
    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
29
    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
30

  
31
<!--
32

  
33
  Checkstyle configuration that checks the sun coding conventions from:
34

  
35
    - the Java Language Specification at
36
      http://java.sun.com/docs/books/jls/second_edition/html/index.html
37

  
38
    - the Sun Code Conventions at http://java.sun.com/docs/codeconv/
39

  
40
    - the Javadoc guidelines at
41
      http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
42

  
43
    - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
44

  
45
    - some best practices
46

  
47
  Checkstyle is very configurable. Be sure to read the documentation at
48
  http://checkstyle.sf.net (or in your downloaded distribution).
49

  
50
  Most Checks are configurable, be sure to consult the documentation.
51

  
52
  To completely disable a check, just comment it out or delete it from the file.
53

  
54
  Finally, it is worth reading the documentation.
55

  
56
-->
57

  
58
<module name="Checker">
59
    <!--
60
        If you set the basedir property below, then all reported file
61
        names will be relative to the specified directory. See
62
        http://checkstyle.sourceforge.net/5.x/config.html#Checker
63

  
64
        <property name="basedir" value="${basedir}"/>
65
    -->
66
    <!-- gvSIG: All project files have the ISO-8859-1 charset -->
67
	<property name="charset" value="ISO-8859-1" />
68

  
69
    <!-- Checks that a package-info.java file exists for each package.     -->
70
    <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
71
	<module name="JavadocPackage">
72
		<property name="allowLegacy" value="true" />
73
	</module>
74

  
75
    <!-- Checks whether files end with a new line.                        -->
76
    <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
77
    <module name="NewlineAtEndOfFile"/>
78

  
79
    <!-- Checks that property files contain the same keys.         -->
80
    <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
81
    <module name="Translation"/>
82
    
83
    <!-- Checks for Size Violations.                    -->
84
    <!-- See http://checkstyle.sf.net/config_sizes.html -->
85
    <module name="FileLength"/>
86
    
87
    <!-- Checks for whitespace                               -->
88
    <!-- See http://checkstyle.sf.net/config_whitespace.html -->
89
    <module name="FileTabCharacter"/>
90

  
91

  
92
    <module name="TreeWalker">
93

  
94
	    <!-- Miscellaneous other checks.                   -->
95
	    <!-- See http://checkstyle.sf.net/config_misc.html -->
96
	    <!-- gvSIG: apply only to java files -->
97
	    <module name="RegexpSinglelineJava">
98
	       <property name="format" value="\s+$"/>
99
	       <property name="minimum" value="0"/>
100
	       <property name="maximum" value="0"/>
101
	       <property name="message" value="Line has trailing spaces."/>
102
	       <property name="ignoreComments" value="true"/>
103
	    </module>
104
	    
105
        <!-- Checks for Javadoc comments.                     -->
106
        <!-- See http://checkstyle.sf.net/config_javadoc.html -->
107
		<!--
108
			gvSIG rule 3: All protected or public classes must have a Javadoc comments,
109
			except getters and setters
110
		-->
111
		<module name="JavadocMethod">
112
			<property name="scope" value="protected" />
113
			<property name="allowMissingPropertyJavadoc" value="true" />
114
		</module>
115
		<!--
116
			gvSIG rule 9: All classes must have a Javadoc comment
117
			with the "@author tag" and the "@version $Id$" tag included 
118
		-->
119
		<module name="JavadocType">
120
			<property name="scope" value="private" />
121
			<property name="authorFormat" value="\S" />
122
			<property name="versionFormat" value="\$Id.*\$"/>
123
		</module>
124
        <module name="JavadocVariable">
125
			<property name="scope" value="protected" />
126
		</module>
127
		<!-- gvSIG rule 3: Check correctly formatted Javadoc -->
128
		<module name="JavadocStyle">
129
			<property name="scope" value="protected" />
130
		</module>
131

  
132

  
133
        <!-- Checks for Naming Conventions.                  -->
134
        <!-- See http://checkstyle.sf.net/config_naming.html -->
135
        <module name="ConstantName"/>
136
        <module name="LocalFinalVariableName"/>
137
        <module name="LocalVariableName"/>
138
        <module name="MemberName"/>
139
        <module name="MethodName"/>
140
		<!-- gvSIG rule 15: All packages must begin with org.gvsig.  -->
141
		<module name="PackageName">
142
			<property name="format" value="^org\.gvsig(\.[a-z][a-z0-9]*)+$" />
143
		</module>
144
		<!-- gvSIG advised rule 1: Abstract class names must begin with Abstract. -->
145
		<!-- module name="AbstractClassName" /-->
146
        <module name="ParameterName"/>
147
        <module name="StaticVariableName"/>
148
        <module name="TypeName"/>
149

  
150
        <!-- Checks for imports                              -->
151
        <!-- See http://checkstyle.sf.net/config_import.html -->
152
        <module name="AvoidStarImport"/>
153
        <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
154
        <module name="RedundantImport"/>
155
        <module name="UnusedImports"/>
156

  
157

  
158
        <!-- Checks for Size Violations.                    -->
159
        <!-- See http://checkstyle.sf.net/config_sizes.html -->
160
        <module name="LineLength"/>
161
        <module name="MethodLength"/>
162
        <module name="ParameterNumber"/>
163

  
164

  
165
        <!-- Checks for whitespace                               -->
166
        <!-- See http://checkstyle.sf.net/config_whitespace.html -->
167
        <module name="EmptyForIteratorPad"/>
168
        <module name="GenericWhitespace"/>
169
        <module name="MethodParamPad"/>
170
        <module name="NoWhitespaceAfter"/>
171
        <module name="NoWhitespaceBefore"/>
172
        <module name="OperatorWrap"/>
173
        <module name="ParenPad"/>
174
        <module name="TypecastParenPad"/>
175
        <module name="WhitespaceAfter"/>
176
        <module name="WhitespaceAround"/>
177

  
178

  
179
        <!-- Modifier Checks                                    -->
180
        <!-- See http://checkstyle.sf.net/config_modifiers.html -->
181
        <module name="ModifierOrder"/>
182
        <module name="RedundantModifier"/>
183

  
184

  
185
        <!-- Checks for blocks. You know, those {}'s         -->
186
        <!-- See http://checkstyle.sf.net/config_blocks.html -->
187
        <module name="AvoidNestedBlocks"/>
188
        <module name="EmptyBlock"/>
189
        <module name="LeftCurly"/>
190
        <module name="NeedBraces"/>
191
        <module name="RightCurly"/>
192

  
193

  
194
        <!-- Checks for common coding problems               -->
195
        <!-- See http://checkstyle.sf.net/config_coding.html -->
196
        <module name="AvoidInlineConditionals"/>
197
        <module name="DoubleCheckedLocking"/>    <!-- MY FAVOURITE -->
198
        <module name="EmptyStatement"/>
199
        <module name="EqualsHashCode"/>
200
        <module name="HiddenField"/>
201
        <module name="IllegalInstantiation"/>
202
        <module name="InnerAssignment"/>
203
        <module name="MagicNumber"/>
204
        <module name="MissingSwitchDefault"/>
205
        <module name="RedundantThrows"/>
206
        <module name="SimplifyBooleanExpression"/>
207
        <module name="SimplifyBooleanReturn"/>
208

  
209
		<!-- gvSIG: Check for some common programming errors -->
210
		<module name="CovariantEquals" />
211
		<module name="StringLiteralEquality" />
212

  
213
        <!-- Checks for class design                         -->
214
        <!-- See http://checkstyle.sf.net/config_design.html -->
215
        <module name="DesignForExtension"/>
216
        <module name="FinalClass"/>
217
        <module name="HideUtilityClassConstructor"/>
218
        <module name="InterfaceIsType"/>
219
        <module name="VisibilityModifier"/>
220

  
221

  
222
        <!-- Miscellaneous other checks.                   -->
223
        <!-- See http://checkstyle.sf.net/config_misc.html -->
224
        <module name="ArrayTypeStyle"/>
225
        <!-- gvSIG: removed -->
226
        <!-- module name="FinalParameters"/-->
227
        <module name="TodoComment"/>
228
        <module name="UpperEll"/>
229
				
230
	    <!-- gvSIG rule 2: Sun style with 4 spaces -->
231
	    <module name="Indentation">
232
	    	<property name="basicOffset" value="4"/>
233
		    <property name="caseIndent" value="0"/>
234
		</module>
235
        
236
        <!-- gvSIG rule 10: Do not use System.out/err to log -->
237
		<module name="Regexp">
238
		    <!-- . matches any character, so we need to escape it and use \. 
239
		    to match dots.-->
240
		    <property name="format" value="System\.[out|err]\.println"/>
241
		    <property name="illegalPattern" value="true"/>
242
		</module>
243
		
244
		<!-- gvSIG rule 11: Try to avoid catching Throwable or 
245
		Exception and catch specific exceptions instead. -->
246
		<module name="IllegalCatch"/>
247
		
248
		<!-- gvSIG rule 13: Use interfaces in the declaration of 
249
		methods and variables.
250
        By default only avoids usage of Classes:
251
			"java.util.GregorianCalendar, java.util.Hashtable, 
252
		  	java.util.HashSet, java.util.HashMap, java.util.ArrayList, 
253
		  	java.util.LinkedList, java.util.LinkedHashMap, 
254
		  	java.util.LinkedHashSet, java.util.TreeSet, 
255
		  	java.util.TreeMap, java.util.Vector" -->
256
		<module name="IllegalType">
257
		    <property name="ignoredMethodNames" value="getInstance"/>
258
		</module>
259
		
260
    </module>
261

  
262
	<!--  gvSIG rule 1: check for the gvSIG header -->
263
    <!-- Uneeded, use the maven-license-plugin instead
264
	<module name="RegexpHeader"> -->
265
		<!-- The follow property value demonstrates the ability     -->
266
		<!-- to have access to ANT properties. In this case it uses -->
267
		<!-- the ${basedir} property to allow Checkstyle to be run  -->
268
		<!-- from any directory within a project. See property      -->
269
		<!-- expansion,                                             -->
270
		<!-- http://checkstyle.sf.net/config.html#properties        -->
271
    <!--
272
		<property name="headerFile" value="${checkstyle.header.file}" />
273
	</module>
274
    -->
275

  
276
</module>
0 277

  
tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.buildtools/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <groupId>org.gvsig</groupId>
5
  <artifactId>org.gvsig.desktop.buildtools</artifactId>
6
  <version>1.0.0</version>
7
  <packaging>jar</packaging>
8
  <name>${project.artifactId}</name>
9
  <description>Resources used for build gvsig desktop</description>
10

  
11

  
12
<!-- No puede ser hijo de org.gvsig.desktop para evitar referencas circulares -->
13
<!--
14
  <parent>
15
    <groupId>org.gvsig</groupId>
16
    <artifactId>org.gvsig.desktop</artifactId>
17
    <version>2.0.10-SNAPSHOT</version>
18
  </parent>  
19
-->
20

  
21

  
22
    <licenses>
23
        <license>
24
            <name>GPLv3</name>
25
            <url>http://www.gnu.org/licenses/gpl.html</url>
26
            <distribution>repo</distribution>
27
            <comments>
28
			"GPL" stands for "General Public License". The most widespread such
29
			license is the GNU General Public License, or GNU GPL for short.
30
			This can be further shortened to "GPL", when it is understood that
31
			the GNU GPL is the one intended.
32
	      	</comments>
33
        </license>
34
    </licenses>
35

  
36
    <organization>
37
        <name>gvSIG Association</name>
38
        <url>http://www.gvsig.com/</url>
39
    </organization>
40

  
41
    <scm>
42
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/trunk</connection>
43
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-desktop/trunk</developerConnection>
44
        <url>https://devel.gvsig.org/redmine/projects/gvsig-desktop/repository/show/trunk</url>
45
    </scm>
46
    
47
    <repositories>
48
      <repository>
49
        <id>gvsig-public-http-repository</id>
50
        <name>gvSIG maven public HTTP repository</name>
51
        <url>http://devel.gvsig.org/m2repo/j2se</url>
52
        <releases>
53
          <enabled>true</enabled>
54
          <updatePolicy>daily</updatePolicy>
55
          <checksumPolicy>warn</checksumPolicy>
56
        </releases>
57
        <snapshots>
58
          <enabled>true</enabled>
59
          <updatePolicy>daily</updatePolicy>
60
          <checksumPolicy>warn</checksumPolicy>
61
        </snapshots>
62
      </repository>
63
    </repositories>
64

  
65
    <distributionManagement>
66
      <site>
67
        <id>gvsig-repository</id>
68
        <url>dav:https://devel.gvsig.org/sites/${project.artifactId}/${project.version}</url>
69
      </site>
70
      <repository>
71
          <id>gvsig-repository</id>
72
          <name>gvSIG maven repository</name>
73
          <url>dav:https://devel.gvsig.org/m2repo/j2se</url>
74
          <uniqueVersion>false</uniqueVersion>
75
      </repository>
76
      <snapshotRepository>
77
          <id>gvsig-repository</id>
78
          <name>gvSIG maven repository</name>
79
          <url>dav:https://devel.gvsig.org/m2repo/j2se</url>
80
          <uniqueVersion>false</uniqueVersion>
81
      </snapshotRepository>
82
    </distributionManagement>
83
    
84
    <issueManagement>
85
      <system>redmine</system>
86
      <url>https://devel.gvsig.org/redmine/projects/gvsig-desktop</url>
87
    </issueManagement>
88

  
89
    <mailingLists>
90
      <mailingList>
91
        <name>User List</name>
92
        <subscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios</subscribe>
93
        <unsubscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_usuarios</unsubscribe>
94
        <post>gvsig_usuarios@listserv.gva.es</post>
95
        <archive>http://www.gvsig.org/web/community/mailing-lists/gvsig-nabble</archive>
96
        <otherArchives>
97
          <otherArchive>http://www.mail-archive.com/gvsig_usuarios@runas.cap.gva.es</otherArchive>
98
          <otherArchive>http://dir.gmane.org/index.php?prefix=gmane.comp.gis.gvsig</otherArchive>
99
        </otherArchives>
100
      </mailingList>
101
      <mailingList>
102
        <name>Developer List</name>
103
        <subscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_desarrolladores</subscribe>
104
        <unsubscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_desarrolladores</unsubscribe>
105
        <post>gvsig_desarrolladores@listserv.gva.es</post>
106
        <archive>http://www.gvsig.org/web/community/mailing-lists/gvsig-nabble</archive>
107
        <otherArchives>
108
          <otherArchive>http://www.mail-archive.com/gvsig_desarrolladores@runas.cap.gva.es</otherArchive>
109
          <otherArchive>http://dir.gmane.org/index.php?prefix=gmane.comp.gis.gvsig</otherArchive>
110
        </otherArchives>
111
      </mailingList>
112
      <mailingList>
113
        <name>International List</name>
114
        <subscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</subscribe>
115
        <unsubscribe>http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional</unsubscribe>
116
        <post>gvsig_internacional@listserv.gva.es</post>
117
        <archive>http://www.gvsig.org/web/community/mailing-lists/gvsig-nabble</archive>
118
        <otherArchives>
119
          <otherArchive>http://www.mail-archive.com/gvsig_internacional@runas.cap.gva.es</otherArchive>
120
          <otherArchive>http://dir.gmane.org/index.php?prefix=gmane.comp.gis.gvsig</otherArchive>
121
        </otherArchives>
122
      </mailingList>
123
    </mailingLists>
124
    
125
    <build>
126
        <extensions>
127
            <extension>
128
                <groupId>org.apache.maven.wagon</groupId>
129
                <artifactId>wagon-webdav-jackrabbit</artifactId>
130
                <version>1.0-beta-7</version>
131
            </extension>
132
        </extensions>
133
    </build>
134

  
135
</project>
0 136

  
tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.library/org.gvsig.utils/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.utils</artifactId>
6
  <packaging>jar</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
      <groupId>org.gvsig</groupId>
10
      <artifactId>org.gvsig.desktop.library</artifactId>
11
      <version>2.0.15</version>
12
  </parent>
13

  
14
  <dependencies>
15
    <dependency>
16
        <groupId>org.gvsig</groupId>
17
        <artifactId>org.gvsig.tools.lib</artifactId>
18
        <scope>compile</scope>
19
    </dependency>
20
    <dependency>
21
        <groupId>org.gvsig</groupId>
22
        <artifactId>org.gvsig.tools.swing.api</artifactId>
23
        <scope>compile</scope>
24
    </dependency>
25
    <dependency>
26
        <groupId>org.gvsig</groupId>
27
        <artifactId>org.gvsig.tools.lib</artifactId>
28
        <type>test-jar</type>
29
        <scope>test</scope>
30
    </dependency>
31
    <dependency>
32
      <groupId>castor</groupId>
33
      <artifactId>castor</artifactId>
34
      <scope>compile</scope>
35
    </dependency>  
36
  </dependencies>
37

  
38
  <build>
39
    
40
    <!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
41
    <plugins>
42
      <plugin>
43
        <groupId>org.apache.maven.plugins</groupId>
44
        <artifactId>maven-surefire-plugin</artifactId>
45
        <configuration>
46
          <skipTests>true</skipTests>
47
        </configuration>
48
      </plugin>
49

  
50
    </plugins>
51
  </build>
52

  
53
</project>
0 54

  
tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.library/org.gvsig.utils/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
30

  
31
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
32
		<layout class="org.apache.log4j.PatternLayout">
33
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
34
		</layout>
35
	</appender>
36

  
37
	<category name="org.gvsig.tools">
38
		<priority value="DEBUG" />
39
	</category>
40

  
41
	<category name="org.gvsig.utils">
42
		<priority value="DEBUG" />
43
	</category>
44

  
45
	<root>
46
		<priority value="INFO" />
47
		<appender-ref ref="CONSOLE" />
48
	</root>
49
</log4j:configuration>
0 50

  
tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/DoubleUtilitiesTest.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils;
25

  
26
import org.gvsig.utils.DoubleUtilities;
27

  
28
import junit.framework.TestCase;
29
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
30
 *
31
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
32
 *
33
 * This program is free software; you can redistribute it and/or
34
 * modify it under the terms of the GNU General Public License
35
 * as published by the Free Software Foundation; either version 2
36
 * of the License, or (at your option) any later version.
37
 *
38
 * This program is distributed in the hope that it will be useful,
39
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
41
 * GNU General Public License for more details.
42
 *
43
 * You should have received a copy of the GNU General Public License
44
 * along with this program; if not, write to the Free Software
45
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
46
 *
47
 * For more information, contact:
48
 *
49
 *  Generalitat Valenciana
50
 *   Conselleria d'Infraestructures i Transport
51
 *   Av. Blasco Ib??ez, 50
52
 *   46010 VALENCIA
53
 *   SPAIN
54
 *
55
 *      +34 963862235
56
 *   gvsig@gva.es
57
 *      www.gvsig.gva.es
58
 *
59
 *    or
60
 *
61
 *   IVER T.I. S.A
62
 *   Salamanca 50
63
 *   46005 Valencia
64
 *   Spain
65
 *
66
 *   +34 963163400
67
 *   dac@iver.es
68
 */
69
/* CVS MESSAGES:
70
 *
71
 * $Id: DoubleUtilitiesTest.java 29631 2009-06-29 16:56:19Z jpiera $
72
 * $Log$
73
 * Revision 1.2  2006-11-06 07:29:59  jaume
74
 * organize imports
75
 *
76
 * Revision 1.1  2006/05/16 13:02:41  jorpiell
77
 * Se ha a?adido la clase DoubleUtiles, donde ha un metodo para limitar el tama?o de los decimales de un double y para quitar los "puntos" de la parte entera
78
 *
79
 *
80
 */
81
/**
82
 * Para probar los double utilities
83
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
84
 */
85
public class DoubleUtilitiesTest extends TestCase {
86
	public void testDouble(){
87
		double numero = 1.36645345645;
88
		numero = DoubleUtilities.format(numero,".".charAt(0),4);
89
		assertEquals(numero,1.3665,0.00000000001);
90
	}
91
}
0 92

  
tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestMathExtension.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils;
25

  
26
import org.gvsig.utils.MathExtension;
27
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
28
 *
29
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
30
 *
31
 * This program is free software; you can redistribute it and/or
32
 * modify it under the terms of the GNU General Public License
33
 * as published by the Free Software Foundation; either version 2
34
 * of the License, or (at your option) any later version.
35
 *
36
 * This program is distributed in the hope that it will be useful,
37
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
39
 * GNU General Public License for more details.
40
 *
41
 * You should have received a copy of the GNU General Public License
42
 * along with this program; if not, write to the Free Software
43
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
44
 *
45
 * For more information, contact:
46
 *
47
 *  Generalitat Valenciana
48
 *   Conselleria d'Infraestructures i Transport
49
 *   Av. Blasco Ib??ez, 50
50
 *   46010 VALENCIA
51
 *   SPAIN
52
 *
53
 *      +34 963862235
54
 *   gvsig@gva.es
55
 *      www.gvsig.gva.es
56
 *
57
 *    or
58
 *
59
 *   IVER T.I. S.A
60
 *   Salamanca 50
61
 *   46005 Valencia
62
 *   Spain
63
 *
64
 *   +34 963163400
65
 *   dac@iver.es
66
 */
67

  
68
/**
69
 * Tests for the MathExtension class
70
 * 
71
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
72
 */
73
public class TestMathExtension {
74
	/**
75
	 * Test method for the TestMathExtension class
76
	 * 
77
	 * @param args
78
	 */
79
	public static void main(String[] args)
80
	{
81
		// Test 1
82
		System.out.println("Test 1 -> log2(1)");
83
		showResultState(0, MathExtension.log2(1), 1);
84

  
85
		// Test 2
86
		System.out.println("Test 2 -> log2(16)");
87
		showResultState(4, MathExtension.log2(16), 2);
88

  
89
		// Test 3
90
		System.out.println("Test 3 -> log2Integer(15)");
91
		showResultState(3, MathExtension.log2Integer(15), 3);
92
		
93
		// Test 4
94
		System.out.println("Test 4 -> log2Integer(64)");
95
		showResultState(6, MathExtension.log2Integer(64), 4);
96
		
97
		// Test 5
98
		System.out.println("Test 5 -> logX(e2, e6)");
99
		showResultState(3, MathExtension.logX(Math.pow(Math.E, 2), Math.pow(Math.E, 6)), 5);
100
		
101
		// Test 6
102
		System.out.println("Test 6 -> logXInteger(5, 137.43)");
103
		showResultState(3, MathExtension.logXInteger(5, 137.43), 6);
104

  
105
		
106
		// There might be more tests
107
		
108
	}
109
	
110
	/**
111
	 * Indicates if the result of the current test has been successfull or not
112
	 * 
113
	 * @param correct The correct result
114
	 * @param result The result of the operation
115
	 * @param testNumber The numer of the current test
116
	 */
117
	private static void showResultState(double correct, double result, int testNumber) {
118
		if (correct == result)
119
			System.out.println("Test " + testNumber + " OK    (Result: " + result + ")");
120
		else
121
			System.out.println("Test " + testNumber + " FAILED    (Result: " + result + ")");
122
	}
123
}
0 124

  
tags/org.gvsig.desktop-2.0.15/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/stringNumberUtilities/TestStringNumberUtilities.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils.stringNumberUtilities;
25

  
26
import org.gvsig.utils.stringNumberUtilities.StringNumberUtilities;
27

  
28
import junit.framework.TestCase;
29

  
30
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
31
 *
32
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
33
 *
34
 * This program is free software; you can redistribute it and/or
35
 * modify it under the terms of the GNU General Public License
36
 * as published by the Free Software Foundation; either version 2
37
 * of the License, or (at your option) any later version.
38
 *
39
 * This program is distributed in the hope that it will be useful,
40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42
 * GNU General Public License for more details.
43
 *
44
 * You should have received a copy of the GNU General Public License
45
 * along with this program; if not, write to the Free Software
46
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
47
 *
48
 * For more information, contact:
49
 *
50
 *  Generalitat Valenciana
51
 *   Conselleria d'Infraestructures i Transport
52
 *   Av. Blasco Ib??ez, 50
53
 *   46010 VALENCIA
54
 *   SPAIN
55
 *
56
 *      +34 963862235
57
 *   gvsig@gva.es
58
 *      www.gvsig.gva.es
59
 *
60
 *    or
61
 *
62
 *   IVER T.I. S.A
63
 *   Salamanca 50
64
 *   46005 Valencia
65
 *   Spain
66
 *
67
 *   +34 963163400
68
 *   dac@iver.es
69
 */
70

  
71
/**
72
 * Tests the methods of the class StringNumberUtilities
73
 * 
74
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
75
 */
76
public class TestStringNumberUtilities extends TestCase{
77
	private String word;
78
	
79
	/*
80
	 *  (non-Javadoc)
81
	 * @see junit.framework.TestCase#setUp()
82
	 */
83
	protected void setUp() throws Exception {
84
		super.setUp();
85
		word = new String();
86
	}
87

  
88
	/*
89
	 *  (non-Javadoc)
90
	 * @see junit.framework.TestCase#tearDown()
91
	 */
92
	protected void tearDown() throws Exception {
93
		super.tearDown();
94
	}
95
	
96
	/**
97
	 * A test
98
	 */
99
	public void test1() {
100
		word = "2.3";
101
		ShowText.showIsNumberText(word);
102

  
103
		if (StringNumberUtilities.isNumber(word)) {
104
			ShowText.showYes();
105
		}
106
		else {
107
			ShowText.showNo();
108
			fail();
109
		}
110
	}
111

  
112
	/**
113
	 * A test
114
	 */
115
	public void test2() {
116
		word = "a as wz rwa";
117
		ShowText.showIsNumberText(word);
118

  
119
		if (StringNumberUtilities.isNumber(word)) {
120
			ShowText.showYes();
121
		}
122
		else {
123
			ShowText.showNo();
124
			fail();
125
		}
126
	}
127

  
128
	/**
129
	 * A test
130
	 */
131
	public void test3() {
132
		word = "2";
133
		ShowText.showIsNumberText(word);
134

  
135
		if (StringNumberUtilities.isNumber(word)) {
136
			ShowText.showYes();
137
		}
138
		else {
139
			ShowText.showNo();
140
			fail();
141
		}
142
	}
143

  
144
	/**
145
	 * A test
146
	 */
147
	public void test4() {
148
		word = "";
149
		ShowText.showIsNumberText(word);
150

  
151
		if (StringNumberUtilities.isNumber(word)) {
152
			ShowText.showYes();
153
		}
154
		else {
155
			ShowText.showNo();
156
			fail();
157
		}
158
	}
159

  
160
	/**
161
	 * A test
162
	 */
163
	public void test5() {
164
		word = "-2.3";
165
		ShowText.showIsNumberText(word);
166

  
167
		if (StringNumberUtilities.isNumber(word)) {
168
			ShowText.showYes();
169
		}
170
		else {
171
			ShowText.showNo();
172
			fail();
173
		}
174
	}
175

  
176
	/**
177
	 * A test
178
	 */
179
	public void test6() {
180
		word = "-300";
181
		ShowText.showIsNumberText(word);
182

  
183
		if (StringNumberUtilities.isNumber(word)) {
184
			ShowText.showYes();
185
		}
186
		else {
187
			ShowText.showNo();
188
			fail();
189
		}
190
	}
191

  
192
	/**
193
	 * A test
194
	 */
195
	public void test7() {
196
		word = "2.3";
197
		ShowText.showIsNaturalText(word);
198

  
199
		if (StringNumberUtilities.isNaturalNumber(word)) {
200
			ShowText.showYes();
201
		}
202
		else {
203
			ShowText.showNo();
204
			fail();
205
		}
206
	}
207

  
208
	/**
209
	 * A test
210
	 */
211
	public void test8() {
212
		word = "334";
213
		ShowText.showIsNaturalText(word);
214

  
215
		if (StringNumberUtilities.isNaturalNumber(word)) {
216
			ShowText.showYes();
217
		}
218
		else {
219
			ShowText.showNo();
220
			fail();
221
		}
222
	}
223

  
224
	/**
225
	 * A test
226
	 */
227
	public void test9() {
228
		word = "-2a3";
229
		ShowText.showIsIntegerText(word);
230

  
231
		if (StringNumberUtilities.isIntegerNumber(word)) {
232
			ShowText.showYes();
233
		}
234
		else {
235
			ShowText.showNo();
236
			fail();
237
		}
238
	}
239

  
240
	/**
241
	 * A test
242
	 */
243
	public void test10() {
244
		word = "-23";
245
		ShowText.showIsIntegerText(word);
246

  
247
		if (StringNumberUtilities.isIntegerNumber(word)) {
248
			ShowText.showYes();
249
		}
250
		else {
251
			ShowText.showNo();
252
			fail();
253
		}
254
	}
255
	
256
	/**
257
	 * A test
258
	 */
259
	public void test11() {
260
		word = "7";
261
		ShowText.showIsIntegerText(word);
262

  
263
		if (StringNumberUtilities.isIntegerNumber(word)) {
264
			ShowText.showYes();
265
		}
266
		else {
267
			ShowText.showNo();
268
			fail();
269
		}
270
	}
271
	
272
	/**
273
	 * A test
274
	 */
275
	public void test12() {
276
		word = "2.3";
277
		ShowText.showIsIntegerText(word);
278

  
279
		if (StringNumberUtilities.isIntegerNumber(word)) {
280
			ShowText.showYes();
281
		}
282
		else {
283
			ShowText.showNo();
284
			fail();
285
		}
286
	}
287

  
288
	/**
289
	 * A test
290
	 */
291
	public void test13() {
292
		word = "2.3";
293
		ShowText.showIsRealText(word);
294

  
295
		if (StringNumberUtilities.isRealNumber(word)) {
296
			ShowText.showYes();
297
		}
298
		else {
299
			ShowText.showNo();
300
			fail();
301
		}
302
	}
303
	
304
	/**
305
	 * A test
306
	 */
307
	public void test14() {
308
		word = "37";
309
		ShowText.showIsRealText(word);
310

  
311
		if (StringNumberUtilities.isRealNumber(word)) {
312
			ShowText.showYes();
313
		}
314
		else {
315
			ShowText.showNo();
316
			fail();
317
		}
318
	}
319
	
320
	/**
321
	 * A test
322
	 */
323
	public void test15() {
324
		word = "-4.6";
325
		ShowText.showIsRealText(word);
326

  
327
		if (StringNumberUtilities.isRealNumber(word)) {
328
			ShowText.showYes();
329
		}
330
		else {
331
			ShowText.showNo();
332
			fail();
333
		}
334
	}
335
	
336
	/**
337
	 * A test
338
	 */
339
	public void test16() {
340
		word = "-8000";
341
		ShowText.showIsRealText(word);
342

  
343
		if (StringNumberUtilities.isRealNumber(word)) {
344
			ShowText.showYes();
345
		}
346
		else {
347
			ShowText.showNo();
348
			fail();
349
		}
350
	}
351

  
352
	/**
353
	 * A test
354
	 */
355
	public void test17() {
356
		word = "-80k00";
357
		ShowText.showIsRealText(word);
358

  
359
		if (StringNumberUtilities.isRealNumber(word)) {
360
			ShowText.showYes();
361
		}
362
		else {
363
			ShowText.showNo();
364
			fail();
365
		}
366
	}
367
		
368
	/**
369
	 * A test
370
	 */
371
	public void test18() {
372
		word = ".6";
373
		ShowText.showIsRealText(word);
374

  
375
		if (StringNumberUtilities.isRealNumber(word)) {
376
			ShowText.showYes();
377
		}
378
		else {
379
			ShowText.showNo();
380
			fail();
381
		}
382
	}
383
	
384
	/**
385
	 * A test
386
	 */
387
	public void test19() {
388
		word = "-.6";
389
		ShowText.showIsRealText(word);
390

  
391
		if (StringNumberUtilities.isRealNumber(word)) {
392
			ShowText.showYes();
393
		}
394
		else {
395
			ShowText.showNo();
396
			fail();
397
		}
398
	}
399
	
400
	/**
401
	 * A test
402
	 */
403
	public void test20() {
404
		word = "b-.6";
405
		ShowText.showIsRealText(word);
406

  
407
		if (StringNumberUtilities.isRealNumber(word)) {
408
			ShowText.showYes();
409
		}
410
		else {
411
			ShowText.showNo();
412
			fail();
413
		}
414
	}
415
	
416
	
417
	/**
418
	 * A test
419
	 */
420
	public void test21() {
421
		word = "-c.6";
422
		ShowText.showIsRealText(word);
423

  
424
		if (StringNumberUtilities.isRealNumber(word)) {
425
			ShowText.showYes();
426
		}
427
		else {
428
			ShowText.showNo();
429
			fail();
430
		}
431
	}
432
	
433
	
434
	/**
435
	 * A test
436
	 */
437
	public void test22() {
438
		word = "-.d6";
439
		ShowText.showIsRealText(word);
440

  
441
		if (StringNumberUtilities.isRealNumber(word)) {
442
			ShowText.showYes();
443
		}
444
		else {
445
			ShowText.showNo();
446
			fail();
447
		}
448
	}
449
	
450
	/**
451
	 * A test
452
	 */
453
	public void test23() {
454
		word = "-.6e";
455
		ShowText.showIsRealText(word);
456

  
457
		if (StringNumberUtilities.isRealNumber(word)) {
458
			ShowText.showYes();
459
		}
460
		else {
461
			ShowText.showNo();
462
			fail();
463
		}
464
	}
465
	
466
	/**
467
	 * A test
468
	 */
469
	public void test24() {
470
		word = "+.6";
471
		ShowText.showIsRealText(word);
472

  
473
		if (StringNumberUtilities.isRealNumber(word)) {
474
			ShowText.showYes();
475
		}
476
		else {
477
			ShowText.showNo();
478
			fail();
479
		}
480
	}
481
	
482
	/**
483
	 * A test
484
	 */
485
	public void test25() {
486
		word = "+.6";
487
		ShowText.showIsRealWithIntegerExponentText(word);
488

  
489
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
490
			ShowText.showYes();
491
		}
492
		else {
493
			ShowText.showNo();
494
			fail();
495
		}
496
	}
497
	
498
	
499
	/**
500
	 * A test
501
	 */
502
	public void test26() {
503
		word = ".6";
504
		ShowText.showIsRealWithIntegerExponentText(word);
505

  
506
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
507
			ShowText.showYes();
508
		}
509
		else {
510
			ShowText.showNo();
511
			fail();
512
		}
513
	}
514

  
515
	
516
	/**
517
	 * A test
518
	 */
519
	public void test27() {
520
		word = "-.6";
521
		ShowText.showIsRealWithIntegerExponentText(word);
522

  
523
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
524
			ShowText.showYes();
525
		}
526
		else {
527
			ShowText.showNo();
528
			fail();
529
		}
530
	}
531

  
532
	
533
	/**
534
	 * A test
535
	 */
536
	public void test28() {
537
		word = "+6";
538
		ShowText.showIsRealWithIntegerExponentText(word);
539

  
540
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
541
			ShowText.showYes();
542
		}
543
		else {
544
			ShowText.showNo();
545
			fail();
546
		}
547
	}
548

  
549
	
550
	/**
551
	 * A test
552
	 */
553
	public void test29() {
554
		word = "-6";
555
		ShowText.showIsRealWithIntegerExponentText(word);
556

  
557
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
558
			ShowText.showYes();
559
		}
560
		else {
561
			ShowText.showNo();
562
			fail();
563
		}
564
	}
565

  
566
	
567
	/**
568
	 * A test
569
	 */
570
	public void test30() {
571
		word = "6";
572
		ShowText.showIsRealWithIntegerExponentText(word);
573

  
574
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
575
			ShowText.showYes();
576
		}
577
		else {
578
			ShowText.showNo();
579
			fail();
580
		}
581
	}
582
	
583
	/**
584
	 * A test
585
	 */
586
	public void test31() {
587
		word = "136.13";
588
		ShowText.showIsRealWithIntegerExponentText(word);
589

  
590
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
591
			ShowText.showYes();
592
		}
593
		else {
594
			ShowText.showNo();
595
			fail();
596
		}
597
	}
598
	
599
	
600
	/**
601
	 * A test
602
	 */
603
	public void test32() {
604
		word = "+13.42";
605
		ShowText.showIsRealWithIntegerExponentText(word);
606

  
607
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
608
			ShowText.showYes();
609
		}
610
		else {
611
			ShowText.showNo();
612
			fail();
613
		}
614
	}
615
	
616
	/**
617
	 * A test
618
	 */
619
	public void test33() {
620
		word = "-246.24";
621
		ShowText.showIsRealWithIntegerExponentText(word);
622

  
623
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
624
			ShowText.showYes();
625
		}
626
		else {
627
			ShowText.showNo();
628
			fail();
629
		}
630
	}
631
	
632
	/**
633
	 * A test
634
	 */
635
	public void test34() {
636
		word = "146.134E+13";
637
		ShowText.showIsRealWithIntegerExponentText(word);
638

  
639
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
640
			ShowText.showYes();
641
		}
642
		else {
643
			ShowText.showNo();
644
			fail();
645
		}
646
	}
647
	
648
	/**
649
	 * A test
650
	 */
651
	public void test35() {
652
		word = "614.425E-67";
653
		ShowText.showIsRealWithIntegerExponentText(word);
654

  
655
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
656
			ShowText.showYes();
657
		}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff