Java常用工具类---UUID工具类、Map工具类

UUID生成工具类 立即下载

package com.jarvis.base.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

/**
 * A class that represents an immutable universally unique identifier (UUID).
 * A UUID represents a 128-bit value.
 * <p/>
 * <p>There exist different variants of these global identifiers. The methods
 * of this class are for manipulating the Leach-Salz variant, although the
 * constructors allow the creation of any variant of UUID (described below).
 * <p/>
 * <p>The layout of a variant 2 (Leach-Salz) UUID is as follows:
 * <p/>
 * The most significant long consists of the following unsigned fields:
 * <pre>
 * 0xFFFFFFFF00000000 time_low
 * 0x00000000FFFF0000 time_mid
 * 0x000000000000F000 version
 * 0x0000000000000FFF time_hi
 * </pre>
 * The least significant long consists of the following unsigned fields:
 * <pre>
 * 0xC000000000000000 variant
 * 0x3FFF000000000000 clock_seq
 * 0x0000FFFFFFFFFFFF node
 * </pre>
 * <p/>
 * <p>The variant field contains a value which identifies the layout of
 * the <tt>UUID</tt>. The bit layout described above is valid only for
 * a <tt>UUID</tt> with a variant value of 2, which indicates the
 * Leach-Salz variant.
 * <p/>
 * <p>The version field holds a value that describes the type of this
 * <tt>UUID</tt>. There are four different basic types of UUIDs: time-based,
 * DCE security, name-based, and randomly generated UUIDs. These types
 * have a version value of 1, 2, 3 and 4, respectively.
 * <p/>
 * <p>For more information including algorithms used to create <tt>UUID</tt>s,
 * see the Internet-Draft <a href="http://www.ietf.org/internet-drafts/draft-mealling-uuid-urn-03.txt">UUIDs and GUIDs</a>
 * or the standards body definition at
 * <a href="http://www.iso.ch/cate/d2229.html">ISO/IEC 11578:1996</a>.
 *
 * @version 1.14, 07/12/04
 * @since 1.5
 */
@Deprecated
public final class UUID implements java.io.Serializable
{

    /**
     * Explicit serialVersionUID for interoperability.
     */
    private static final long serialVersionUID = -4856846361193249489L;

    /*
     * The most significant 64 bits of this UUID.
     *
     * @serial
     */
    private final long mostSigBits;

    /**
     * The least significant 64 bits of this UUID.
     *
     * @serial
     */
    private final long leastSigBits;

    /*
     * The version number associated with this UUID. Computed on demand.
     */
    private transient int version = -1;

    /*
     * The variant number associated with this UUID. Computed on demand.
     */
    private transient int variant = -1;

    /*
     * The timestamp associated with this UUID. Computed on demand.
     */
    private transient volatile long timestamp = -1;

    /*
     * The clock sequence associated with this UUID. Computed on demand.
     */
    private transient int sequence = -1;

    /*
     * The node number associated with this UUID. Computed on demand.
     */
    private transient long node = -1;

    /*
     * The hashcode of this UUID. Computed on demand.
     */
    private transient int hashCode = -1;

    /*
     * The random number generator used by this class to create random
     * based UUIDs.
     */
    private static volatile SecureRandom numberGenerator = null;

    // Constructors and Factories

    /*
     * Private constructor which uses a byte array to construct the new UUID.
     */
    private UUID(byte[] data)
    {
        long msb = 0;
        long lsb = 0;
        for (int i = 0; i < 8; i++)
            msb = (msb << 8) | (data[i] & 0xff);
        for (int i = 8; i < 16; i++)
            lsb = (lsb << 8) | (data[i] & 0xff);
        this.mostSigBits = msb;
        this.leastSigBits = lsb;
    }

    /**
     * Constructs a new <tt>UUID</tt> using the specified data.
     * <tt>mostSigBits</tt> is used for the most significant 64 bits
     * of the <tt>UUID</tt> and <tt>leastSigBits</tt> becomes the
     * least significant 64 bits of the <tt>UUID</tt>.
     *
     * @param mostSigBits
     * @param leastSigBits
     */
    public UUID(long mostSigBits, long leastSigBits)
    {
        this.mostSigBits = mostSigBits;
        this.leastSigBits = leastSigBits;
    }

    /**
     * Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
     * <p/>
     * The <code>UUID</code> is generated using a cryptographically strong
     * pseudo random number generator.
     *
     * @return a randomly generated <tt>UUID</tt>.
     */
    @SuppressWarnings("unused")
    public static UUID randomUUID()
    {
        SecureRandom ng = numberGenerator;
        if (ng == null)
        {
            numberGenerator = ng = new SecureRandom();
        }

        byte[] randomBytes = new byte[16];
        ng.nextBytes(randomBytes);
        randomBytes[6] &= 0x0f;  /* clear version        */
        randomBytes[6] |= 0x40;  /* set to version 4     */
        randomBytes[8] &= 0x3f;  /* clear variant        */
        randomBytes[8] |= 0x80;  /* set to IETF variant  */
        UUID result = new UUID(randomBytes);
        return new UUID(randomBytes);
    }

    /**
     * Static factory to retrieve a type 3 (name based) <tt>UUID</tt> based on
     * the specified byte array.
     *
     * @param name a byte array to be used to construct a <tt>UUID</tt>.
     * @return a <tt>UUID</tt> generated from the specified array.
     */
    public static UUID nameUUIDFromBytes(byte[] name)
    {
        MessageDigest md;
        try
        {
            md = MessageDigest.getInstance("MD5");
        }
        catch (NoSuchAlgorithmException nsae)
        {
            throw new InternalError("MD5 not supported");
        }
        byte[] md5Bytes = md.digest(name);
        md5Bytes[6] &= 0x0f;  /* clear version        */
        md5Bytes[6] |= 0x30;  /* set to version 3     */
        md5Bytes[8] &= 0x3f;  /* clear variant        */
        md5Bytes[8] |= 0x80;  /* set to IETF variant  */
        return new UUID(md5Bytes);
    }

    /**
     * Creates a <tt>UUID</tt> from the string standard representation as
     * described in the {@link #toString} method.
     *
     * @param name a string that specifies a <tt>UUID</tt>.
     * @return a <tt>UUID</tt> with the specified value.
     * @throws IllegalArgumentException if name does not conform to the
     *                                  string representation as described in {@link #toString}.
     */
    public static UUID fromString(String name)
    {
        String[] components = name.split("-");
        if (components.length != 5)
            throw new IllegalArgumentException("Invalid UUID string: " + name);
        for (int i = 0; i < 5; i++)
            components[i] = "0x" + components[i];

        long mostSigBits = Long.decode(components[0]).longValue();
        mostSigBits <<= 16;
        mostSigBits |= Long.decode(components[1]).longValue();
        mostSigBits <<= 16;
        mostSigBits |= Long.decode(components[2]).longValue();

        long leastSigBits = Long.decode(components[3]).longValue();
        leastSigBits <<= 48;
        leastSigBits |= Long.decode(components[4]).longValue();

        return new UUID(mostSigBits, leastSigBits);
    }

    // Field Accessor Methods

    /**
     * Returns the least significant 64 bits of this UUID's 128 bit value.
     *
     * @return the least significant 64 bits of this UUID's 128 bit value.
     */
    public long getLeastSignificantBits()
    {
        return leastSigBits;
    }

    /**
     * Returns the most significant 64 bits of this UUID's 128 bit value.
     *
     * @return the most significant 64 bits of this UUID's 128 bit value.
     */
    public long getMostSignificantBits()
    {
        return mostSigBits;
    }

    /**
     * The version number associated with this <tt>UUID</tt>. The version
     * number describes how this <tt>UUID</tt> was generated.
     * <p/>
     * The version number has the following meaning:<p>
     * <ul>
     * <li>1    Time-based UUID
     * <li>2    DCE security UUID
     * <li>3    Name-based UUID
     * <li>4    Randomly generated UUID
     * </ul>
     *
     * @return the version number of this <tt>UUID</tt>.
     */
    public int version()
    {
        if (version < 0)
        {
            // Version is bits masked by 0x000000000000F000 in MS long
            version = (int) ((mostSigBits >> 12) & 0x0f);
        }
        return version;
    }

    /**
     * The variant number associated with this <tt>UUID</tt>. The variant
     * number describes the layout of the <tt>UUID</tt>.
     * <p/>
     * The variant number has the following meaning:<p>
     * <ul>
     * <li>0    Reserved for NCS backward compatibility
     * <li>2    The Leach-Salz variant (used by this class)
     * <li>6    Reserved, Microsoft Corporation backward compatibility
     * <li>7    Reserved for future definition
     * </ul>
     *
     * @return the variant number of this <tt>UUID</tt>.
     */
    public int variant()
    {
        if (variant < 0)
        {
            // This field is composed of a varying number of bits
            if ((leastSigBits >>> 63) == 0)
            {
                variant = 0;
            }
            else if ((leastSigBits >>> 62) == 2)
            {
                variant = 2;
            }
            else
            {
                variant = (int) (leastSigBits >>> 61);
            }
        }
        return variant;
    }

    /**
     * The timestamp value associated with this UUID.
     * <p/>
     * <p>The 60 bit timestamp value is constructed from the time_low,
     * time_mid, and time_hi fields of this <tt>UUID</tt>. The resulting
     * timestamp is measured in 100-nanosecond units since midnight,
     * October 15, 1582 UTC.<p>
     * <p/>
     * The timestamp value is only meaningful in a time-based UUID, which
     * has version type 1. If this <tt>UUID</tt> is not a time-based UUID then
     * this method throws UnsupportedOperationException.
     *
     * @throws UnsupportedOperationException if this UUID is not a
     *                                       version 1 UUID.
     */
    public long timestamp()
    {
        if (version() != 1)
        {
            throw new UnsupportedOperationException("Not a time-based UUID");
        }
        long result = timestamp;
        if (result < 0)
        {
            result = (mostSigBits & 0x0000000000000FFFL) << 48;
            result |= ((mostSigBits >> 16) & 0xFFFFL) << 32;
            result |= mostSigBits >>> 32;
            timestamp = result;
        }
        return result;
    }

    /**
     * The clock sequence value associated with this UUID.
     * <p/>
     * <p>The 14 bit clock sequence value is constructed from the clock
     * sequence field of this UUID. The clock sequence field is used to
     * guarantee temporal uniqueness in a time-based UUID.<p>
     * <p/>
     * The  clockSequence value is only meaningful in a time-based UUID, which
     * has version type 1. If this UUID is not a time-based UUID then
     * this method throws UnsupportedOperationException.
     *
     * @return the clock sequence of this <tt>UUID</tt>.
     * @throws UnsupportedOperationException if this UUID is not a
     *                                       version 1 UUID.
     */
    public int clockSequence()
    {
        if (version() != 1)
        {
            throw new UnsupportedOperationException("Not a time-based UUID");
        }
        if (sequence < 0)
        {
            sequence = (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
        }
        return sequence;
    }

    /**
     * The node value associated with this UUID.
     * <p/>
     * <p>The 48 bit node value is constructed from the node field of
     * this UUID. This field is intended to hold the IEEE 802 address
     * of the machine that generated this UUID to guarantee spatial
     * uniqueness.<p>
     * <p/>
     * The node value is only meaningful in a time-based UUID, which
     * has version type 1. If this UUID is not a time-based UUID then
     * this method throws UnsupportedOperationException.
     *
     * @return the node value of this <tt>UUID</tt>.
     * @throws UnsupportedOperationException if this UUID is not a
     *                                       version 1 UUID.
     */
    public long node()
    {
        if (version() != 1)
        {
            throw new UnsupportedOperationException("Not a time-based UUID");
        }
        if (node < 0)
        {
            node = leastSigBits & 0x0000FFFFFFFFFFFFL;
        }
        return node;
    }

    // Object Inherited Methods

    /**
     * Returns a <code>String</code> object representing this
     * <code>UUID</code>.
     * <p/>
     * <p>The UUID string representation is as described by this BNF :
     * <pre>
     *  UUID                   = <time_low> "-" <time_mid> "-"
     *                           <time_high_and_version> "-"
     *                           <variant_and_sequence> "-"
     *                           <node>
     *  time_low               = 4*<hexOctet>
     *  time_mid               = 2*<hexOctet>
     *  time_high_and_version  = 2*<hexOctet>
     *  variant_and_sequence   = 2*<hexOctet>
     *  node                   = 6*<hexOctet>
     *  hexOctet               = <hexDigit><hexDigit>
     *  hexDigit               =
     *        "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
     *        | "a" | "b" | "c" | "d" | "e" | "f"
     *        | "A" | "B" | "C" | "D" | "E" | "F"
     * </pre>
     *
     * @return a string representation of this <tt>UUID</tt>.
     */
    public String toString()
    {
        return (digits(mostSigBits >> 32, 8) + "-" +
                digits(mostSigBits >> 16, 4) + "-" +
                digits(mostSigBits, 4) + "-" +
                digits(leastSigBits >> 48, 4) + "-" +
                digits(leastSigBits, 12));
    }

    /**
     * Returns val represented by the specified number of hex digits.
     */
    private static String digits(long val, int digits)
    {
        long hi = 1L << (digits * 4);
        return Long.toHexString(hi | (val & (hi - 1))).substring(1);
    }

    /**
     * Returns a hash code for this <code>UUID</code>.
     *
     * @return a hash code value for this <tt>UUID</tt>.
     */
    public int hashCode()
    {
        if (hashCode == -1)
        {
            hashCode = (int) ((mostSigBits >> 32) ^
                    mostSigBits ^
                    (leastSigBits >> 32) ^
                    leastSigBits);
        }
        return hashCode;
    }

    /**
     * Compares this object to the specified object.  The result is
     * <tt>true</tt> if and only if the argument is not
     * <tt>null</tt>, is a <tt>UUID</tt> object, has the same variant,
     * and contains the same value, bit for bit, as this <tt>UUID</tt>.
     *
     * @param obj the object to compare with.
     * @return <code>true</code> if the objects are the same;
     *         <code>false</code> otherwise.
     */
    public boolean equals(Object obj)
    {
        if (!(obj instanceof UUID))
            return false;
        if (((UUID) obj).variant() != this.variant())
            return false;
        UUID id = (UUID) obj;
        return (mostSigBits == id.mostSigBits &&
                leastSigBits == id.leastSigBits);
    }

    // Comparison Operations

    /**
     * Compares this UUID with the specified UUID.
     * <p/>
     * <p>The first of two UUIDs follows the second if the most significant
     * field in which the UUIDs differ is greater for the first UUID.
     *
     * @param val <tt>UUID</tt> to which this <tt>UUID</tt> is to be compared.
     * @return -1, 0 or 1 as this <tt>UUID</tt> is less than, equal
     *         to, or greater than <tt>val</tt>.
     */
    public int compareTo(UUID val)
    {
        // The ordering is intentionally set up so that the UUIDs
        // can simply be numerically compared as two numbers
        return (this.mostSigBits < val.mostSigBits ? -1 :
                (this.mostSigBits > val.mostSigBits ? 1 :
                        (this.leastSigBits < val.leastSigBits ? -1 :
                                (this.leastSigBits > val.leastSigBits ? 1 :
                                        0))));
    }

    /**
     * Reconstitute the <tt>UUID</tt> instance from a stream (that is,
     * deserialize it). This is necessary to set the transient fields
     * to their correct uninitialized value so they will be recomputed
     * on demand.
     */
    private void readObject(java.io.ObjectInputStream in)
            throws java.io.IOException, ClassNotFoundException
    {

        in.defaultReadObject();

        // Set "cached computation" fields to their initial values
        version = -1;
        variant = -1;
        timestamp = -1;
        sequence = -1;
        node = -1;
        hashCode = -1;
    }
   
}


package com.jarvis.base.util;

import java.util.Map;
/**
 *   
 * 
 * @Title: MapHelper.java
 * @Package com.jarvis.base.util
 * @Description:Map工具类
 * @version V1.0  
 */
public class MapHelper {
    /**
     * 获得字串值
     *
     * @param name
     *            键值名称
     * @return 若不存在,则返回空字串
     */
    public static String getString(Map<?, ?> map, String name) {
        if (name == null || name.equals("")) {
            return "";
        }

        String value = "";
        if (map.containsKey(name) == false) {
            return "";
        }
        Object obj = map.get(name);
        if (obj != null) {
            value = obj.toString();
        }
        obj = null;

        return value;
    }

    /**
     * 返回整型值
     *
     * @param name
     *            键值名称
     * @return 若不存在,或转换失败,则返回0
     */
    public static int getInt(Map<?, ?> map, String name) {
        if (name == null || name.equals("")) {
            return 0;
        }

        int value = 0;
        if (map.containsKey(name) == false) {
            return 0;
        }

        Object obj = map.get(name);
        if (obj == null) {
            return 0;
        }

        if (!(obj instanceof Integer)) {
            try {
                value = Integer.parseInt(obj.toString());
            } catch (Exception ex) {
                ex.printStackTrace();
                System.err.println("name[" + name + "]对应的值不是数字,返回0");
                value = 0;
            }
        } else {
            value = ((Integer) obj).intValue();
            obj = null;
        }

        return value;
    }

    /**
     * 获取长整型值
     *
     * @param name
     *            键值名称
     * @return 若不存在,或转换失败,则返回0
     */
    public static long getLong(Map<?, ?> map, String name) {
        if (name == null || name.equals("")) {
            return 0;
        }

        long value = 0;
        if (map.containsKey(name) == false) {
            return 0;
        }

        Object obj = map.get(name);
        if (obj == null) {
            return 0;
        }

        if (!(obj instanceof Long)) {
            try {
                value = Long.parseLong(obj.toString());
            } catch (Exception ex) {
                ex.printStackTrace();
                System.err.println("name[" + name + "]对应的值不是数字,返回0");
                value = 0;
            }
        } else {
            value = ((Long) obj).longValue();
            obj = null;
        }

        return value;
    }

    /**
     * 获取Float型值
     *
     * @param name
     *            键值名称
     * @return 若不存在,或转换失败,则返回0
     */
    public static float getFloat(Map<?, ?> map, String name) {
        if (name == null || name.equals("")) {
            return 0;
        }

        float value = 0;
        if (map.containsKey(name) == false) {
            return 0;
        }

        Object obj = map.get(name);
        if (obj == null) {
            return 0;
        }

        if (!(obj instanceof Float)) {
            try {
                value = Float.parseFloat(obj.toString());
            } catch (Exception ex) {
                ex.printStackTrace();
                System.err.println("name[" + name + "]对应的值不是数字,返回0");
                value = 0;
            }
        } else {
            value = ((Float) obj).floatValue();
            obj = null;
        }

        return value;
    }

    /**
     * 获取Double型值
     *
     * @param name
     *            键值名称
     * @return 若不存在,或转换失败,则返回0
     */
    public static double getDouble(Map<?, ?> map, String name) {
        if (name == null || name.equals("")) {
            return 0;
        }

        double value = 0;
        if (map.containsKey(name) == false) {
            return 0;
        }

        Object obj = map.get(name);
        if (obj == null) {
            return 0;
        }

        if (!(obj instanceof Double)) {
            try {
                value = Double.parseDouble(obj.toString());
            } catch (Exception ex) {
                ex.printStackTrace();
                System.err.println("name[" + name + "]对应的值不是数字,返回0");
                value = 0;
            }
        } else {
            value = ((Double) obj).doubleValue();
            obj = null;
        }

        return value;
    }

    /**
     * 获取Bool值
     *
     * @param name
     *            键值名称
     * @return 若不存在,或转换失败,则返回false
     */
    public static boolean getBoolean(Map<?, ?> map, String name) {
        if (name == null || name.equals("")) {
            return false;
        }

        boolean value = false;
        if (map.containsKey(name) == false) {
            return false;
        }
        Object obj = map.get(name);
        if (obj == null) {
            return false;
        }

        if (obj instanceof Boolean) {
            return ((Boolean) obj).booleanValue();
        }

        value = Boolean.valueOf(obj.toString()).booleanValue();
        obj = null;
        return value;
    }
}
 

手把手教你用Qt和DSP28335实现串口Bootloader,附赠源码和避坑指南 本文详细介绍了如何使用Qt和DSP28335实现串口Bootloader,包括开发环境搭建、通信协议设计、Qt上位机开发、DSP端Bootloader核心实现以及应用程序工程的特殊配置。通过实战案例和源码分享,帮助开发者快速掌握嵌入式固件升级技术,提升工业设备远程升级的效率和可靠性。 阅读详情

相关推荐

实测iOS和安卓大不同!用NFC触发小程序跳转的完整避坑指南(含NFC Tools配置)

本文深入解析iOS与安卓在NFC触发小程序跳转时的核心差异,提供微信与支付宝小程序的NFC实现方案及优化技巧。涵盖跨平台兼容性测试方法论、性能优化策略及异常处理方案,帮助开发者避开常见陷阱,提升跳转成功率。特别针对NFC Tools配置和微信Universal Link使用进行详细指导。

asdfghjkl978564的博客 437

UUID 工具类

UUID   UUID 是通用唯一识别码(Universally Unique Identifier)的缩写。UUID 让分布式系统中的所有元素,都能有唯一的辨识信息,而不需要通过中央控制端来做辨识信息的指定。 UUID 的组成 1~8位采用系统时间,在系统时间上精确到毫秒级保证时间上的惟一性; 9~16位采用底层的IP地址,在服务器集群中的惟一性; 17~24位采用当前对象的HashCode值,在一个内部对象上的惟一性; 25~32位采用调用方法的一个随机数,在一个对象内的毫秒级的惟一性。 UUID

Acx7的博客 3542

嵌入式充电协议深度解析:从QC到PD3.1的技术演进与实战应用

本文深入解析了从QC到PD3.1的嵌入式充电协议技术演进与实战应用。通过电压谈判、协议芯片设计、Type-C接口优化等关键技术,详细介绍了快充协议在嵌入式系统中的实现挑战与解决方案,包括兼容性测试、EMC问题处理及空间限制创新设计,为开发者提供了宝贵的实践经验。

weixin_29194817的博客 421

java-UUID 生成工具类(UUIDUtils)

Java中有一个类叫做UUID,它可以用来生成唯一标识符。为了方便使用,我们可以创建一个UUIDUtils工具类来封装UUID的生成逻辑。首先,我们需要导入java.util.UUID类。然后,在UUIDUtils类中,我们可以定义一个静态方法来生成UUID。该方法应该返回一个字符串表示的UUID。在生成UUID之前,我们可以使用UUID类的randomUUID方法来创建一个新的UUID对象。然后,我们可以使用toString方法将UUID转换为字符串表示。

Flying_Fish_roe的博客 5524

别再踩坑了!Win10下用阿狸狗V3.2.6安装Cadence SPB 17.4的保姆级避坑指南

本文提供了Win10系统下使用阿狸狗V3.2.6安装Cadence SPB 17.4的详细避坑指南,涵盖环境准备、安装失败清理、分步安装与问题诊断、授权配置及典型故障排除等内容,帮助用户顺利完成安装并避免常见错误。

weixin_32576389的博客 360

网络工程师的Python入门实战:手把手教你写交换机配置备份脚本

本文详细介绍了如何利用Python为网络工程师开发一个高效的交换机配置备份脚本,涵盖环境搭建、设备连接方案、智能设备发现、多因素认证、异常处理、配置差异对比等关键步骤。通过实战案例展示如何将备份时间从4小时缩短至15分钟,显著提升运维效率,特别适用于华为交换机等设备的配置导出与备份需求。

weixin_30291791的博客 305

java 生成UUID字符串工具类 UUIDUtil

/ 去掉空格符和换行符。* 生成32位UUID 即:不包含字符-的UUID。* 生成36位UUID 即:包含字符-的UUID。* @param count 指定数目。* @param count 指定数目。* @param count 指定数目。* 生成指定数目的指定位数的uuid。* 生成指定数目的32位uuid。* 生成指定数目的36位uuid。* 生成12位uuid的一部分。* 生成UUID字符串。

shengguimin的博客 2413

(OSTrack)Joint Feature Learning and Relation Modeling for Tracking A One-Stream Framework

Joint Feature Learning and Relation Modeling for Tracking A One-Stream Framework (OSTrack)

小火山的博客 1653

【亲测免费】 MapHelper 使用指南

MapHelper 使用指南 项目介绍 MapHelper 是一个由 Jenly 开发的开源项目,旨在简化 Android 开发中地图相关功能的集成与使用。它提供了一种高效且直观的方式来处理地图界面与标注点管理,支持Google Maps API和其他主流地图SDK的集成,极大地提升了开发者在实现地图功能时的效率与便捷性。无论是添加自定义标记、处理点击事件还是复杂的地图交互逻辑,MapHelper...

gitblog_00205的博客 1143

V90伺服 EPOS模式下回原(详细配置+SCL源代码)

/ 输出上限 100.0%rSetPoint : Real;// 设置目标值工程量。// 通道转换参考值。Td : Real;

RXXW_Dor的博客 2666

【云原生之Docker实战】使用docker部署Monica个人开源CRM系统

【云原生之Docker实战】使用docker部署Monica个人开源CRM系统

jks212454的博客 2390

UUID工具类

UUID工具类

佳佳太难了的博客 271

MaxScript批量修改材质、贴图名称

MaxScript批量修改材质、贴图名称1 实现效果1.1 修改前材质、贴图名称1.2 修改后2 代码 1 实现效果 1.1 修改前材质、贴图名称 1.2 修改后 2 代码 prefixName = "prefiname" maxFile = "maxfilepath" makeDir "newBitmappath" mapsPath = newbitmappath + "\\" fn formatStr index = ( str = index as string newS

郑德帅 3241

java as uuid_java常用工具类 UUID、Map工具类

本文实例为大家分享了Java常用工具类 的具体代码,供大家参考,具体内容如下UUID工具类package com.jarvis.base.util;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.security.SecureRandom;/*** A clas...

weixin_42550052的博客 269

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Java常用工具类详解

本文深入解析Java中Math的数学运算、Random的随机数生成、System的系统交互及UUID的唯一标识符生成,涵盖常用方法、底层原理与实战场景,通过代码示例演示数学计算优化、高效随机算法、系统资源管理及分布式ID生成,助你掌握核心工具类,提升开发效率与代码健壮性。

m0_73941339的博客 964

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

小小工具类(web学习常用工具类)

1. jdbc工具类,获取连接池中的连接工具类(不包括事务的处理) package jdbc; import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import com.mchange.v2.c3p0.ComboPooledDataSource; public class ...

weixin_43394342的博客 195

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

java常见类——工具类

目录工具类Java开发者写好的类---官方文档 API包装类(封装类)数学相关Math类Random类UUID类BigInteger类BigDecima类 超过了double取值范围DecimalFormatScanner类System类日期相关Date类DateFormat类Calendar类 1.1版本TimeZone字符串String类---->引用类型 java.lang包StringBuffer和StringBuilder知识总结集合相关(ArrayBox LinkedBox

RRros的博客 5294

Java 工具类--CommonUtils

功能: 1、产生长度为32的字符串,且不重复 2、将Map对象转化为制定的JavaBean对象 package com.acme.utils; import java.util.Map; import java.util.UUID; import org.apache.commons.beanutils.BeanUtils; /** * 公用工具类 * @author acme.w

冰轩 1790

小工具(1):项目所需小工具之CommonUtils(1生成uuid,2Map转换成JavaBean)

1、导入源代码:    1、执行

u014071328的专栏 6109

java 中把map类型转换成指定类型

首先创建一个user类,用于封装数据. package cn.itcast.test; public class User { private String loginname; //登录名 private String loginpass; //登录密码 private String age; private String birthday; public Strin...

周杰伦 1万+

28个java常用工具类_28个Java常用的工具类

Base64.javaBase64DecodingException.javaCConst.javaCharTools.javaConfigHelper.javaCounter.javaCTool.javaDateHandler.javaDateUtil.javaDealString.javaDebugOut.javaDom4jHelper.javaEscape.javaExecHelper.ja...

weixin_34947914的博客 620

Java常用工具类

       在实际开发中我们会用到很多参数处理,或者是加密,等等,下面我总结出我做个各项目中我们使用的工具类,基本已经都在线上运行,可以借鉴,使用。 /** * 说明:MD5处理 * @version */ public class MD5 { public static String md5(String str) { try { MessageDigest md =...

枫叶 348

java工具类,常用工具方法

我就存一个工具类:ToolUtils.java import com.chenggutek.cloud.riskctrl.biz.cashloan.comm.model.base.constant.CashloanConstants; import org.apache.commons.lang3.StringUtils; import java.io.IOException; imp...

monica1_1的博客 634

CommonUtils类下uuid生成随机数,ToBean键值对封装到类

jar下载地址//download.youkuaiyun.com/download/qq_42391248/12089304 commons.CommonUtils类下的uuid()方法 返回一个随机的32长的字符串 * 用途: * 1.用来做id,数据库表中的主键是不能重复的,它就是不重复的! * 2.不能重复的东西都可以用它! import java.util.Has...

WonderKing'blog 716

java 生成有序uuid的工具类

无序的uuid的生成,用于数据库id,不利于索引排序。有序的uuid 可以解决这一问题。亲测多线程大量生成,也是有序不重复的。

liwang2016384的博客 1855

03-32位UUID和封装Map对象到指定类型的Bean中

1.封装CommonUtils,生成UUID 导入jar包:commons-beanutils-1.8.3.jar,而它依赖了commons-logging-1.1.1.jar 有以下两个接口: String uuid():生成长度32的随机字符,通常用来做实体类的ID。底层使用了UUID类完成; T toBean(Map, Class):把Map转换成指定类型的Bean对象。

...... 738
上一篇: springMVC的功能和优点
下一篇: Linux用户和组管理
冷丶
博客等级 码龄8年 1粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值