Revision 44941
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/CSVStoreProvider.java | ||
---|---|---|
456 | 456 |
private void init(CSVStoreParameters parameters, DataStoreProviderServices storeServices) { |
457 | 457 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
458 | 458 |
} |
459 |
private class FieldTypeParser { |
|
459 |
|
|
460 |
public static class FieldTypeParser { |
|
460 | 461 |
|
461 | 462 |
public String name = null; |
462 | 463 |
public int type = DataTypes.STRING; |
... | ... | |
471 | 472 |
|
472 | 473 |
private String typename = "string"; |
473 | 474 |
|
474 |
FieldTypeParser() { |
|
475 |
private final String fullFileName; |
|
476 |
private final String providerName; |
|
477 |
|
|
478 |
FieldTypeParser(String providerName, String fullFileName) { |
|
479 |
this.providerName = providerName; |
|
480 |
this.fullFileName = fullFileName; |
|
475 | 481 |
} |
476 | 482 |
|
483 |
public String getProviderName() { |
|
484 |
return this.providerName; |
|
485 |
} |
|
486 |
|
|
487 |
public String getFullFileName() { |
|
488 |
return this.fullFileName; |
|
489 |
} |
|
490 |
|
|
477 | 491 |
public void clear() { |
478 | 492 |
this.name = null; |
479 | 493 |
this.type = DataTypes.STRING; |
... | ... | |
606 | 620 |
// Calculamos cuales pueden ser los tipos de datos |
607 | 621 |
// |
608 | 622 |
for (int i = 0; i < fieldTypes.length; i++) { |
609 |
fieldTypes[i] = new FieldTypeParser(); |
|
623 |
fieldTypes[i] = new FieldTypeParser(getProviderName(), getFullFileName());
|
|
610 | 624 |
} |
611 | 625 |
|
612 | 626 |
// Asuminos los tipos pasados por parametro, que se supone |
... | ... | |
633 | 647 |
String sep = CSVStoreParameters.getDelimiter(param_types_def); |
634 | 648 |
if (StringUtils.isNotBlank(sep)) { |
635 | 649 |
String[] param_types = param_types_def.split(sep); |
636 |
FieldTypeParser parser = new FieldTypeParser(); |
|
650 |
FieldTypeParser parser = new FieldTypeParser(getProviderName(), getFullFileName());
|
|
637 | 651 |
for (String param_type : param_types) { |
638 | 652 |
parser.clear(); |
639 | 653 |
parser.parse(param_type); |
... | ... | |
651 | 665 |
// |
652 | 666 |
for (FieldTypeParser fieldType : fieldTypes) { |
653 | 667 |
EditableFeatureAttributeDescriptor fad = fType.add(fieldType.name, fieldType.type); |
654 |
fad.setRequiredBytes(Math.max(fieldType.detectedValue.getDisplaySize(), fieldType.size)); |
|
655 |
fad.setSize(Math.max(fieldType.detectedValue.getDisplaySize(), fieldType.size)); |
|
656 |
if( fad.getPrecision()<fieldType.detectedValue.getPrecision() ) { |
|
657 |
fad.setPrecision(fieldType.detectedValue.getPrecision()); |
|
668 |
if( fieldType.detectedValue!=null ) { |
|
669 |
fad.setRequiredBytes(Math.max(fieldType.detectedValue.getDisplaySize(), fieldType.size)); |
|
670 |
fad.setSize(Math.max(fieldType.detectedValue.getDisplaySize(), fieldType.size)); |
|
671 |
if( fad.getPrecision()<fieldType.detectedValue.getPrecision() ) { |
|
672 |
fad.setPrecision(fieldType.detectedValue.getPrecision()); |
|
673 |
} |
|
674 |
if( fad.getScale()<fieldType.detectedValue.getScale()) { |
|
675 |
fad.setScale(fieldType.detectedValue.getScale()); |
|
676 |
} |
|
677 |
} else { |
|
678 |
fad.setRequiredBytes(fieldType.size); |
|
658 | 679 |
} |
659 |
if( fad.getScale()<fieldType.detectedValue.getScale()) { |
|
660 |
fad.setScale(fieldType.detectedValue.getScale()); |
|
661 |
} |
|
662 | 680 |
if (fieldType.type == DataTypes.GEOMETRY ) { |
663 | 681 |
fad.setGeometryType(fieldType.geomType, fieldType.geomSubtype); |
664 | 682 |
if( fType.getDefaultGeometryAttributeName() == null ) { |
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/DefaultEditableFeatureAttributeDescriptor.java | ||
---|---|---|
489 | 489 |
if( StringUtils.isBlank(name)) { |
490 | 490 |
throw new IllegalArgumentException("Name can't be empty"); |
491 | 491 |
} |
492 |
switch(name.toLowerCase()) { |
|
492 |
String ss; |
|
493 |
switch(name.trim().toLowerCase()) { |
|
493 | 494 |
case "isreadonly": |
494 | 495 |
case "readonly": |
495 | 496 |
this.setIsReadOnly(DataTypeUtils.toBoolean(value, false)); |
... | ... | |
578 | 579 |
case "relation": |
579 | 580 |
this.setRelationType(toRelation(value)); |
580 | 581 |
break; |
582 |
case "name": |
|
583 |
this.setName(DataTypeUtils.toString(value, null)); |
|
584 |
break; |
|
585 |
case "type": |
|
586 |
case "datatype": |
|
587 |
ss = DataTypeUtils.toString(value, null); |
|
588 |
if( !StringUtils.isBlank(ss) ) { |
|
589 |
this.setDataType(ToolsLocator.getDataTypesManager().getType(ss)); |
|
590 |
} |
|
591 |
break; |
|
581 | 592 |
default: |
582 | 593 |
throw new IllegalArgumentException("Name attribute '"+name+"' not valid."); |
583 | 594 |
} |
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 | ||
---|---|---|
1575 | 1575 |
return true; |
1576 | 1576 |
} |
1577 | 1577 |
|
1578 |
private String getAll() { |
|
1579 |
StringBuilder builder = new StringBuilder(); |
|
1580 |
builder.append(this.name).append("__"); |
|
1581 |
builder.append(this.dataType.getName()); |
|
1582 |
if( this.size>0 ) { |
|
1583 |
builder.append("__set__size=").append(this.size); |
|
1584 |
} |
|
1585 |
if( this.precision>0 ) { |
|
1586 |
builder.append("__set__precision=").append(this.precision); |
|
1587 |
} |
|
1588 |
if( this.isHidden() ) { |
|
1589 |
builder.append("__set__hidden=true"); |
|
1590 |
} |
|
1591 |
if( this.isReadOnly() ) { |
|
1592 |
builder.append("__set__readonly=true"); |
|
1593 |
} |
|
1594 |
builder.append("__set__allownull=").append(this.allowNull()); |
|
1595 |
if( this.isPrimaryKey()) { |
|
1596 |
builder.append("__set__pk=true"); |
|
1597 |
} |
|
1598 |
if( this.isAutomatic()) { |
|
1599 |
builder.append("__set__automatic=true"); |
|
1600 |
} |
|
1601 |
if( this.isTime()) { |
|
1602 |
builder.append("__set__istime=true"); |
|
1603 |
} |
|
1604 |
if( !StringUtils.isBlank(this.getDataProfileName()) ) { |
|
1605 |
builder.append("__set__profile=").append(this.getDataProfileName()); |
|
1606 |
} |
|
1607 |
if( !StringUtils.isBlank(this.getGroup()) ) { |
|
1608 |
builder.append("__set__group=").append(this.getGroup()); |
|
1609 |
} |
|
1610 |
if( !StringUtils.isBlank(this.description) ) { |
|
1611 |
builder.append("__set__description=").append(this.description); |
|
1612 |
} |
|
1613 |
if( !StringUtils.isBlank(this.label) ) { |
|
1614 |
builder.append("__set__label=").append(this.label); |
|
1615 |
} |
|
1616 |
if( !StringUtils.isBlank(this.shortLabel) ) { |
|
1617 |
builder.append("__set__shortLabel=").append(this.shortLabel); |
|
1618 |
} |
|
1619 |
if( this.locale!=null ) { |
|
1620 |
builder.append("__set__locale=").append(this.getLocale()); |
|
1621 |
} |
|
1622 |
builder.append("__set__order=").append(this.getOder()); |
|
1623 |
if( this.getSRS()!=null ) { |
|
1624 |
builder.append("__set__srs=").append(this.getSRS().getAbrev()); |
|
1625 |
} |
|
1626 |
if( this.getGeomType()!=null ) { |
|
1627 |
builder.append("__set__geomtype=").append(this.getGeomType().getFullName().replace(":", "@")); |
|
1628 |
} |
|
1629 |
return builder.toString(); |
|
1630 |
} |
|
1631 |
|
|
1578 | 1632 |
@Override |
1579 | 1633 |
public Object get(String name) { |
1580 | 1634 |
if (StringUtils.isBlank(name)) { |
1581 | 1635 |
throw new IllegalArgumentException("Name can't be empty"); |
1582 | 1636 |
} |
1583 |
switch (name.toLowerCase()) { |
|
1637 |
switch (name.trim().toLowerCase()) { |
|
1638 |
case "all": |
|
1639 |
return this.getAll(); |
|
1584 | 1640 |
case "isreadonly": |
1585 | 1641 |
case "readonly": |
1586 | 1642 |
return this.isReadOnly(); |
Also available in: Unified diff