Java Code Examples for com.nextgis.maplib.datasource.Field#getName()

The following examples show how to use com.nextgis.maplib.datasource.Field#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextEdit.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void init(Field field,
                 Bundle savedState,
                 Cursor featureCursor){
    ControlHelper.setClearAction(this);

    mFieldName = field.getName();
    String text = "";

    if (ControlHelper.hasKey(savedState, mFieldName))
        text = savedState.getString(ControlHelper.getSavedStateKey(mFieldName));
    else if (null != featureCursor) {
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0)
            text = featureCursor.getString(column);
    }

    setText(text);

    switch (field.getType()) {

        case GeoConstants.FTString:
            break;

        case GeoConstants.FTInteger:
            setSingleLine(true);
            setInputType(InputType.TYPE_CLASS_NUMBER);
            break;

        case GeoConstants.FTReal:
            setSingleLine(true);
            setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            break;
    }
}
 
Example 2
Source File: ModifyAttributesActivity.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Object putFieldValue(
        ContentValues values,
        Field field)
{
    String fieldName = field.getName();
    IControl control = mFields.get(fieldName);

    if (null == control) {
        return null;
    }

    Object value = control.getValue();
    fieldName = "'" + fieldName + "'";

    if (null != value) {
        Log.d(TAG, "field: " + field.getName() + " value: " + value.toString());

        if (value instanceof Long) {
            values.put(fieldName, (Long) value);
        } else if (value instanceof Integer) {
            values.put(fieldName, (Integer) value);
        } else if (value instanceof String) {
            values.put(fieldName, (String) value);
        } else if (value instanceof Double) {
            values.put(fieldName, (Double) value);
        } else if (value instanceof Float) {
            values.put(fieldName, (Float) value);
        }
    }

    return value;
}
 
Example 3
Source File: VectorLayer.java    From android_maplib with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void createField(Field field)
        throws SQLiteException
{
    if (null == mFields || mFields.isEmpty()) //the db table is not yet created
    {
        return;
    }
    if (mFields.containsKey(field.getName())) {
        return;
    }

    if (!LayerUtil.isFieldNameValid(field.getName())) {
        return;
    } else {
        field.setName(LayerUtil.normalizeFieldName(field.getName()));
    }

    mFields.put(field.getName(), field);

    String fieldCreate = "ALTER TABLE " + mPath.getName() + " ADD COLUMN '" + field.getName() + "'";

    switch (field.getType()) {
        case FTString:
            fieldCreate += " TEXT";
            break;
        case FTInteger:
            fieldCreate += " INTEGER";
            break;
        case FTReal:
            fieldCreate += " REAL";
            break;
        case FTDateTime:
        case FTDate:
        case FTTime:
            fieldCreate += " TIMESTAMP";
            break;
    }

    MapContentProviderHelper map = (MapContentProviderHelper) MapBase.getInstance();
    SQLiteDatabase db = map.getDatabase(false);
    db.execSQL(fieldCreate);
}