Ignore:
Timestamp:
2013-01-27T20:07:53+01:00 (11 years ago)
Author:
bastiK
Message:

some simple refactoring

Location:
trunk/src/org/openstreetmap/josm/data
Files:
1 added
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r5679 r5681  
    1818 */
    1919public class GpxData extends WithAttributes {
    20 
    21     public static final String META_PREFIX = "meta.";
    22     public static final String META_AUTHOR_NAME = META_PREFIX + "author.name";
    23     public static final String META_AUTHOR_EMAIL = META_PREFIX + "author.email";
    24     public static final String META_AUTHOR_LINK = META_PREFIX + "author.link";
    25     public static final String META_COPYRIGHT_AUTHOR = META_PREFIX + "copyright.author";
    26     public static final String META_COPYRIGHT_LICENSE = META_PREFIX + "copyright.license";
    27     public static final String META_COPYRIGHT_YEAR = META_PREFIX + "copyright.year";
    28     public static final String META_DESC = META_PREFIX + "desc";
    29     public static final String META_KEYWORDS = META_PREFIX + "keywords";
    30     public static final String META_LINKS = META_PREFIX + "links";
    31     public static final String META_NAME = META_PREFIX + "name";
    32     public static final String META_TIME = META_PREFIX + "time";
    33     public static final String META_EXTENSIONS = META_PREFIX + "extensions";
    34 
    35     public static final String JOSM_EXTENSIONS_NAMESPACE_URI = "http://josm.openstreetmap.de/gpx-extensions";
    3620
    3721    public File storageFile;
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    r3119 r5681  
    1515 */
    1616
    17 public interface GpxTrack {
     17public interface GpxTrack extends IWithAttributes {
    1818
    1919    Collection<GpxTrackSegment> getSegments();
  • trunk/src/org/openstreetmap/josm/data/gpx/IWithAttributes.java

    r5677 r5681  
    1 // License: GPL.
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.gpx;
    33
    44import java.util.Collection;
    5 import java.util.HashMap;
    6 import java.util.Map;
    75
    86/**
    9  * Base class for various classes in the GPX model.
    10  *
    11  * @author Frederik Ramm <frederik@remote.org>
    12  * @since 444
     7 * Object with attributes.
    138 */
    14 public class WithAttributes {
    15 
    16     /**
    17      * The "attr" hash is used to store the XML payload (not only XML attributes!)
    18      */
    19     public Map<String, Object> attr = new HashMap<String, Object>(0);
     9public interface IWithAttributes {
    2010
    2111    /**
     
    2717     *         or {@code null} if this map contains no String mapping for the key
    2818     */
    29     public String getString(String key) {
    30         Object value = attr.get(key);
    31         return (value instanceof String) ? (String)value : null;
    32     }
     19    String getString(String key);
    3320   
    3421    /**
     
    4128     * @since 5502
    4229     */
    43     public Collection<?> getCollection(String key) {
    44         Object value = attr.get(key);
    45         return (value instanceof Collection<?>) ? (Collection<?>)value : null;
    46     }
     30    Collection<?> getCollection(String key);
    4731}
  • trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java

    r5170 r5681  
    1111import org.openstreetmap.josm.data.Bounds;
    1212
    13 public class ImmutableGpxTrack implements GpxTrack {
     13public class ImmutableGpxTrack extends WithAttributes implements GpxTrack {
    1414
    15     private final Map<String, Object> attributes;
    1615    private final Collection<GpxTrackSegment> segments;
    1716    private final double length;
     
    2524            }
    2625        }
    27         this.attributes = Collections.unmodifiableMap(new HashMap<String, Object>(attributes));
     26        this.attr = Collections.unmodifiableMap(new HashMap<String, Object>(attributes));
    2827        this.segments = Collections.unmodifiableCollection(newSegments);
    2928        this.length = calculateLength();
     
    5554    }
    5655
     56    @Override
    5757    public Map<String, Object> getAttributes() {
    58         return attributes;
     58        return attr;
    5959    }
    6060
     61    @Override
    6162    public Bounds getBounds() {
    6263        if (bounds == null)
     
    6667    }
    6768
     69    @Override
    6870    public double length() {
    6971        return length;
    7072    }
    7173
     74    @Override
    7275    public Collection<GpxTrackSegment> getSegments() {
    7376        return segments;
    7477    }
    7578
     79    @Override
    7680    public int getUpdateCount() {
    7781        return 0;
  • trunk/src/org/openstreetmap/josm/data/gpx/WithAttributes.java

    r5502 r5681  
    1 // License: GPL.
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.gpx;
    33
     
    77
    88/**
     9 * Default implementation for IWithAttributes.
     10 *
    911 * Base class for various classes in the GPX model.
    1012 *
     
    1214 * @since 444
    1315 */
    14 public class WithAttributes {
     16public class WithAttributes implements IWithAttributes, GpxConstants {
    1517
    1618    /**
     
    2022
    2123    /**
    22      * Returns the String value to which the specified key is mapped, 
     24     * Returns the String value to which the specified key is mapped,
    2325     * or {@code null} if this map contains no String mapping for the key.
    24      * 
     26     *
    2527     * @param key the key whose associated value is to be returned
    26      * @return the String value to which the specified key is mapped, 
     28     * @return the String value to which the specified key is mapped,
    2729     *         or {@code null} if this map contains no String mapping for the key
    2830     */
     31    @Override
    2932    public String getString(String key) {
    3033        Object value = attr.get(key);
    3134        return (value instanceof String) ? (String)value : null;
    3235    }
    33    
     36
    3437    /**
    35      * Returns the Collection value to which the specified key is mapped, 
     38     * Returns the Collection value to which the specified key is mapped,
    3639     * or {@code null} if this map contains no Collection mapping for the key.
    37      * 
     40     *
    3841     * @param key the key whose associated value is to be returned
    39      * @return the Collection value to which the specified key is mapped, 
     42     * @return the Collection value to which the specified key is mapped,
    4043     *         or {@code null} if this map contains no Collection mapping for the key
    4144     * @since 5502
    4245     */
     46    @Override
    4347    public Collection<?> getCollection(String key) {
    4448        Object value = attr.get(key);
  • trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    r5671 r5681  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.data.validation;
    23
Note: See TracChangeset for help on using the changeset viewer.