Ignore:
Timestamp:
2009-11-24T10:45:04+01:00 (14 years ago)
Author:
stoecker
Message:

i18n updated, fixed files to reduce problems when applying patches, fix #4017

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagModel.java

    r2040 r2512  
    66
    77public class TagModel {
    8        
    9         /** the name of the tag */
    10         private String name = null;
    11        
    12         /** the list of values */
    13         private ArrayList<String> values = null;
    14        
    15         /**
    16          * constructor
    17          */
    18         public TagModel() {
    19                 values = new ArrayList<String>();
    20                 setName("");
    21                 setValue("");
    22         }
    23        
    24         /**
    25          * constructor
    26          * @param name the tag name
    27          */
    28         public TagModel(String name) {
    29                 this();
    30                 setName(name);
    31         }
    32        
    33         /**
    34          * constructor
    35          *
    36          * @param name the tag name
    37          * @param value the tag value
    38          */
    39         public TagModel(String name, String value) {
    40                 this();
    41                 setName(name);
    42                 setValue(value);
    43         }
    44        
    45         /**
    46          * sets the name. Converts name to "" if null.
    47          * @param name the tag name
    48          */
    49         public void setName(String name) {
    50                 name = (name == null) ? "" : name;
    51                 this.name = name;
    52         }
    53        
    54         /**
    55          * @return the tag name
    56          */
    57         public String getName(){
    58                 return name;
    59         }
    60        
    61         /**
    62          * removes all values from the list of values
    63          */
    64         public void clearValues() {
    65                 this.values.clear();
    66         }
    67        
    68         /**
    69          * sets a unique value for this tag. Converts value to "", if null.
    70          * @param value the value.
    71          */
    72         public void setValue(String value) {
    73                 value = (value == null) ? "" : value;
    74                 clearValues();
    75                 this.values.add(value);
    76         }
    77        
    78         /**
    79          *
    80          * @param value the value to be checked; converted to "" if null
    81          * @return true, if the values of this tag include <code>value</code>; false otherwise
    82          */
    83         public boolean hasValue(String value) {
    84                 value = (value == null) ? "" : value;
    85                 return values.contains(value);
    86         }
    87        
    88         public void addValue(String value) {
    89                 value = (value == null) ? "" : value;
    90                 if (hasValue(value)) {
    91                         return;
    92                 }
    93                 values.add(value);
    94         }
    95        
    96        
    97         /**
    98          * removes a value from the list of values. Converts value to "" if null
    99          * @param value the value
    100          */
    101         public void removeValue(String value){
    102                 value = (value == null) ? "" : value;
    103                 values.remove(value);
    104         }       
    105        
    106         public List<String> getValues() {
    107                 return values;
    108         }
    109        
    110         public String getValue() {
    111                 if (getValueCount() == 0) {
    112                         return "";
    113                 } else if (getValueCount() == 1) {
    114                         return values.get(0);
    115                 } else {
    116                         StringBuilder sb = new StringBuilder();                 
    117                         for (int i =0; i < values.size(); i++) {
    118                                 sb.append(values.get(i));
    119                                 if (i + 1 < values.size()) {
    120                                         sb.append(";");
    121                                 }
    122                         }
    123                         return sb.toString();
    124                 }
    125         }
    126        
    127         public int getValueCount() {
    128                 return values.size();
    129         }
     8
     9    /** the name of the tag */
     10    private String name = null;
     11
     12    /** the list of values */
     13    private ArrayList<String> values = null;
     14
     15    /**
     16     * constructor
     17     */
     18    public TagModel() {
     19        values = new ArrayList<String>();
     20        setName("");
     21        setValue("");
     22    }
     23
     24    /**
     25     * constructor
     26     * @param name the tag name
     27     */
     28    public TagModel(String name) {
     29        this();
     30        setName(name);
     31    }
     32
     33    /**
     34     * constructor
     35     *
     36     * @param name the tag name
     37     * @param value the tag value
     38     */
     39    public TagModel(String name, String value) {
     40        this();
     41        setName(name);
     42        setValue(value);
     43    }
     44
     45    /**
     46     * sets the name. Converts name to "" if null.
     47     * @param name the tag name
     48     */
     49    public void setName(String name) {
     50        name = (name == null) ? "" : name;
     51        this.name = name;
     52    }
     53
     54    /**
     55     * @return the tag name
     56     */
     57    public String getName(){
     58        return name;
     59    }
     60
     61    /**
     62     * removes all values from the list of values
     63     */
     64    public void clearValues() {
     65        this.values.clear();
     66    }
     67
     68    /**
     69     * sets a unique value for this tag. Converts value to "", if null.
     70     * @param value the value.
     71     */
     72    public void setValue(String value) {
     73        value = (value == null) ? "" : value;
     74        clearValues();
     75        this.values.add(value);
     76    }
     77
     78    /**
     79     *
     80     * @param value the value to be checked; converted to "" if null
     81     * @return true, if the values of this tag include <code>value</code>; false otherwise
     82     */
     83    public boolean hasValue(String value) {
     84        value = (value == null) ? "" : value;
     85        return values.contains(value);
     86    }
     87
     88    public void addValue(String value) {
     89        value = (value == null) ? "" : value;
     90        if (hasValue(value)) {
     91            return;
     92        }
     93        values.add(value);
     94    }
     95
     96    /**
     97     * removes a value from the list of values. Converts value to "" if null
     98     * @param value the value
     99     */
     100    public void removeValue(String value){
     101        value = (value == null) ? "" : value;
     102        values.remove(value);
     103    }
     104
     105    public List<String> getValues() {
     106        return values;
     107    }
     108
     109    public String getValue() {
     110        if (getValueCount() == 0) {
     111            return "";
     112        } else if (getValueCount() == 1) {
     113            return values.get(0);
     114        } else {
     115            StringBuilder sb = new StringBuilder();
     116            for (int i =0; i < values.size(); i++) {
     117                sb.append(values.get(i));
     118                if (i + 1 < values.size()) {
     119                    sb.append(";");
     120                }
     121            }
     122            return sb.toString();
     123        }
     124    }
     125
     126    public int getValueCount() {
     127        return values.size();
     128    }
    130129}
Note: See TracChangeset for help on using the changeset viewer.