Revision 44818

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionEvaluatorManager.java
10 10

  
11 11

  
12 12
public interface ExpressionEvaluatorManager extends ScriptManager {
13
    
13
  
14
    public static final String DYNAMICTEXT_STARTTAG =   "<%";
15
    public static final String DYNAMICTEXT_ENDTAG =   "%>";
16
  
14 17
    public Object evaluate(String source);
15 18
    
16 19
    public Object evaluate(SymbolTable symbolTable, String source);
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionUtils.java
4 4
import org.apache.commons.lang3.ArrayUtils;
5 5
import org.apache.commons.lang3.StringUtils;
6 6
import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
7
import static org.gvsig.expressionevaluator.ExpressionEvaluatorManager.DYNAMICTEXT_ENDTAG;
8
import static org.gvsig.expressionevaluator.ExpressionEvaluatorManager.DYNAMICTEXT_STARTTAG;
7 9

  
8 10
/**
9 11
 *
......
170 172
            return null;
171 173
        }
172 174
        if( insert ) {
173
            return "<%=" + source + "%>";
175
            return DYNAMICTEXT_STARTTAG+ "=" + source + DYNAMICTEXT_ENDTAG;
174 176
        }
175
        return "<%" + source + "%>";
177
        return DYNAMICTEXT_STARTTAG + source + DYNAMICTEXT_ENDTAG;
176 178
    }
177 179
    
178 180
    public static boolean isDynamicText(String source) {
179
        String[] sources = StringUtils.substringsBetween(source, "<%", "%>");
181
        if( !source.contains(DYNAMICTEXT_STARTTAG) ) {
182
          return false;
183
        }
184
        String[] sources = StringUtils.substringsBetween(source, DYNAMICTEXT_STARTTAG, DYNAMICTEXT_ENDTAG);
180 185
        if( ArrayUtils.isEmpty(sources) ) {
181 186
            return false;
182 187
        }
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultExpressionEvaluatorManager.java
138 138
    
139 139
    @Override
140 140
    public boolean isDynamicText(String source) {
141
        String[] sources = StringUtils.substringsBetween(source, "<%", "%>");
141
        String[] sources = StringUtils.substringsBetween(source, DYNAMICTEXT_STARTTAG, DYNAMICTEXT_ENDTAG);
142 142
        if( ArrayUtils.isEmpty(sources) ) {
143 143
            return false;
144 144
        }
......
147 147
    
148 148
    @Override
149 149
    public String evaluateDynamicText(SymbolTable symbolTable, String source) {
150
        String[] sources = StringUtils.substringsBetween(source, "<%", "%>");
150
        String[] sources = StringUtils.substringsBetween(source, DYNAMICTEXT_STARTTAG, DYNAMICTEXT_ENDTAG);
151 151
        if( ArrayUtils.isEmpty(sources) ) {
152 152
            return source;
153 153
        }
......
172 172
                interpreter.run(code);
173 173
                values[i] = writer.toString();
174 174
            }
175
            sources[i] = "<%"+sources[i]+"%>";
175
            sources[i] = DYNAMICTEXT_STARTTAG+sources[i]+DYNAMICTEXT_ENDTAG;
176 176
        }
177 177
        String output = StringUtils.replaceEach(source, sources, values);
178 178
        return output;
179 179

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java
182 182
    this.isAutomatic = false;
183 183
    this.hidden = false;
184 184
    this.relationType = RELATION_TYPE_NONE;
185
    this.locale = Locale.ENGLISH;
185
    this.locale = null;
186 186
  }
187 187

  
188 188
  protected DefaultFeatureAttributeDescriptor(
......
306 306
    return allowNull;
307 307
  }
308 308

  
309
  @Override
309 310
  public Locale getLocale() {
311
    if( this.locale == null ) {
312
      if( this.dataType.isNumeric() ) {
313
        this.locale = Locale.ENGLISH;
314
      } else {
315
        this.locale = Locale.getDefault();
316
      }
317
    }
310 318
    return this.locale;
311 319
  }
312 320

  
......
736 744
    state.set("scale", scale);
737 745
    state.set("roundMode", roundMode);
738 746
    try {
739
      state.set("locale", toString.coerce(this.locale));
747
      if( this.locale == null ) {
748
        state.setNull("locale");
749
      } else {
750
        state.set("locale", toString.coerce(this.locale));
751
      }
740 752
    } catch (CoercionException ex) {
741 753
      state.setNull("locale");
742 754
    }
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeature.java
38 38
import org.apache.commons.lang3.ArrayUtils;
39 39
import org.apache.commons.lang3.StringUtils;
40 40
import org.cresques.cts.IProjection;
41
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
42
import org.gvsig.expressionevaluator.ExpressionUtils;
41 43
import org.gvsig.fmap.dal.DALLocator;
42 44
import org.gvsig.fmap.dal.DataTypes;
43 45
import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException;
......
256 258
            if (attribute.getDefaultValue() == null && !attribute.allowNull()) {
257 259
                continue;
258 260
            }
259
            this.set(attribute, attribute.getDefaultValue());
261
            Object value =  attribute.getDefaultValue();
262
            if( value instanceof CharSequence ) {
263
              String s = ((CharSequence)value).toString();
264
              if( ExpressionUtils.isDynamicText(s) ) {
265
                try {
266
                  value = ExpressionUtils.evaluateDynamicText(s);
267
                } catch(Throwable th) {
268
                  value = null;
269
                }
270
              }
271
            }
272
            this.set(attribute, value);
260 273
        }
261 274
    }
262 275

  

Also available in: Unified diff