Package net.jcores.jre.options

Examples of net.jcores.jre.options.ID


     * default a new, unique ID is returned.
     * @return Returns an ID.
     */
    @SupportsOption(options = { ID.class })
    public String uniqueID(Option... options) {
        final ID id = Options.$(this.commonCore, options).ID();
       
       
        if(id == ID.SYSTEM || id == ID.USER) {
            try {
                // System nodes apparently fail for Lion when syncing() (see Issue #15).
                final Preferences node = id == ID.SYSTEM ? Preferences.systemNodeForPackage(getClass()) : Preferences.userNodeForPackage(getClass());

                final String rval = node.get("system.id", "UNAVAILABLE");
                if("UNAVAILABLE".equals(rval)) {
                    String newid = UUID.randomUUID().toString();
                    node.put("system.id", newid);
                    node.sync();
                    return newid;
                }
                return rval;
            } catch(Exception e) {
                Options.$(this.commonCore, options).failure(null, e, "uniqueid:create", "Error getting the ID " + id.getClass() + " (on Lion this might be a bug).");
                return "UNAVAILABLE";
            }
        }
       
        return UUID.randomUUID().toString();
View Full Code Here

TOP

Related Classes of net.jcores.jre.options.ID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.