src/main/java/de/blau/android/presets/PresetItem.java
/**
     * Create a JSON representation of this item
     * 
     * @return JSON format string
     */
Create a JSON representation of this item

@return JSON format string
Create a JSON representation of this item @return JSON format string
public String toJSON() {
        StringBuilder presetNameBuilder = new StringBuilder(name);
        PresetElement p = getParent();
        while (p != null && p != preset.getRootGroup() && !"".equals(p.getName())) {
            presetNameBuilder.insert(0, '/');
            presetNameBuilder.insert(0, p.getName());
            p = p.getParent();
        }
        String presetName = presetNameBuilder.toString();
        StringBuilder jsonString = new StringBuilder();
        for (Entry<String, PresetFixedField> entry : fixedTags.entrySet()) {
            if (jsonString.length() != 0) {
                jsonString.append(",\n");
            }
            jsonString.append(tagToJSON(presetName, entry.getKey(), entry.getValue().getValue()));
        }
        for (Entry<String, PresetField> entry : fields.entrySet()) {
            PresetField field = entry.getValue();
            if (field instanceof PresetFixedField) {
                continue;
            }
            String k = entry.getKey();
            MatchType match = getMatchType(k);
            boolean editable = field instanceof PresetComboField && ((PresetComboField) field).isEditable();
            if (editable || field instanceof PresetTextField || field instanceof PresetCheckField
                    || (match != null && match != MatchType.KEY_VALUE && match != MatchType.KEY)) {
                if (jsonString.length() != 0) {
                    jsonString.append(",\n");
                }
                jsonString.append(tagToJSON(presetName, k, null));
            }
            if (field instanceof PresetComboField && !editable
                    && (match == null || match == MatchType.KEY_VALUE || match == MatchType.KEY || match == MatchType.KEY_VALUE_NEG)) {
                for (StringWithDescription v : ((PresetComboField) entry.getValue()).getValues()) {
                    if (jsonString.length() != 0) {
                        jsonString.append(",\n");
                    }
                    jsonString.append(tagToJSON(presetName, k, v));
                }
            }
        }
        return jsonString.toString();
    }
public String toJSON ( ) { StringBuilder presetNameBuilder = new StringBuilder ( name ) ; PresetElement p = getParent ( ) ; while ( p != null && p != preset . getRootGroup ( ) && ! "" . equals ( p . getName ( ) ) ) { presetNameBuilder . insert ( 0 , '/' ) ; presetNameBuilder . insert ( 0 , p . getName ( ) ) ; p = p . getParent ( ) ; } String presetName = presetNameBuilder . toString ( ) ; StringBuilder jsonString = new StringBuilder ( ) ; for ( Entry < String , PresetFixedField > entry : fixedTags . entrySet ( ) ) { if ( jsonString . length ( ) != 0 ) { jsonString . append ( ",\n" ) ; } jsonString . append ( tagToJSON ( presetName , entry . getKey ( ) , entry . getValue ( ) . getValue ( ) ) ) ; } for ( Entry < String , PresetField > entry : fields . entrySet ( ) ) { PresetField field = entry . getValue ( ) ; if ( field instanceof PresetFixedField ) { continue ; } String k = entry . getKey ( ) ; MatchType match = getMatchType ( k ) ; boolean editable = field instanceof PresetComboField && ( ( PresetComboField ) field ) . isEditable ( ) ; if ( editable || field instanceof PresetTextField || field instanceof PresetCheckField || ( match != null && match != MatchType . KEY_VALUE && match != MatchType . KEY ) ) { if ( jsonString . length ( ) != 0 ) { jsonString . append ( ",\n" ) ; } jsonString . append ( tagToJSON ( presetName , k , null ) ) ; } if ( field instanceof PresetComboField && ! editable && ( match == null || match == MatchType . KEY_VALUE || match == MatchType . KEY || match == MatchType . KEY_VALUE_NEG ) ) { for ( StringWithDescription v : ( ( PresetComboField ) entry . getValue ( ) ) . getValues ( ) ) { if ( jsonString . length ( ) != 0 ) { jsonString . append ( ",\n" ) ; } jsonString . append ( tagToJSON ( presetName , k , v ) ) ; } } } return jsonString . toString ( ) ; }
Create a JSON representation of this item
Create a JSON representation of this item
// check match attribute