Revision 2885

View differences:

org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/namestranslator/TrimNamesTranslator.java
80 80
        for (int i = 0; i < 255; i++) {
81 81
            if (len <= this.maxNameLen) {
82 82
                if (i <= 9) {
83
                    if (len == this.maxNameLen) {
84
                        translatedName = sourceName.substring(0, this.maxNameLen - 3) + "_" + i;
83
                    if (len+2 > this.maxNameLen) {
84
                        translatedName = sourceName.substring(0, this.maxNameLen - 2) + "_" + i;
85 85
                    } else {
86 86
                        translatedName = sourceName + "_" + i;
87 87
                    }
88 88
                } else if (i <= 99) {
89
                    if (len == this.maxNameLen) {
90
                        translatedName = sourceName.substring(0, this.maxNameLen - 3) + i;
89
                    if (len+2 > this.maxNameLen) {
90
                        translatedName = sourceName.substring(0, this.maxNameLen - 2) + i;
91 91
                    } else {
92 92
                        translatedName = sourceName + i;
93 93
                    }
94 94
                } else {
95
                    if (len == this.maxNameLen - 1) {
96
                        translatedName = sourceName.substring(0, this.maxNameLen - 4) + i;
95
                    if (len+3 > this.maxNameLen - 1) {
96
                        translatedName = sourceName.substring(0, this.maxNameLen - 3) + i;
97 97
                    } else {
98 98
                        translatedName = sourceName + i;
99 99
                    }
......
101 101

  
102 102
            } else {
103 103
                if (i == 0) {
104
                    translatedName = sourceName.substring(0, this.maxNameLen - 1);
104
                    translatedName = sourceName.substring(0, this.maxNameLen);
105 105
                } else if (i <= 9) {
106
                    translatedName = sourceName.substring(0, this.maxNameLen - 3) + "_" + i;
106
                    translatedName = sourceName.substring(0, this.maxNameLen - 2) + "_" + i;
107 107
                } else if (i <= 99) {
108
                    translatedName = sourceName.substring(0, this.maxNameLen - 2) + i;
109
                } else {
108 110
                    translatedName = sourceName.substring(0, this.maxNameLen - 3) + i;
109
                } else {
110
                    translatedName = sourceName.substring(0, this.maxNameLen - 4) + i;
111 111
                }
112 112
            }
113 113
            if (!this.translatedNames.contains(translatedName)) {

Also available in: Unified diff