Changeset 6899 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2014-03-06T20:42:57+01:00 (10 years ago)
Author:
bastiK
Message:

see #9784 - md5 hashcode in mapcss

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r6896 r6899  
    1919import java.util.regex.Matcher;
    2020import java.util.regex.Pattern;
     21import java.util.zip.CRC32;
    2122
    2223import org.openstreetmap.josm.Main;
     
    204205
    205206        /**
     207         * Create color from hsb color model. (arguments form 0.0 to 1.0)
     208         * @param h hue
     209         * @param s saturation
     210         * @param b brightness
     211         * @return the corresponding color
     212         */
     213        public static Color hsb_color(float h, float s, float b) {
     214            try {
     215                return Color.getHSBColor(h, s, b);
     216            } catch (IllegalArgumentException e) {
     217                return null;
     218            }
     219        }
     220
     221        /**
    206222         * Creates a color value from an HTML notation, i.e., {@code #rrggbb}.
    207223         */
     
    552568        public static String XML_encode(String s) {
    553569            return s == null ? null : XmlWriter.encode(s);
     570        }
     571
     572        /**
     573         * Calculate the CRC32 checksum from a string
     574         * @param s the string
     575         * @return long value from 0 to 2^32-1
     576         */
     577        public static long CRC32_checksum(String s) {
     578            CRC32 cs = new CRC32();
     579            cs.update(s.getBytes());
     580            return cs.getValue();
    554581        }
    555582    }
Note: See TracChangeset for help on using the changeset viewer.