List of usage examples for java.lang Integer toHexString
public static String toHexString(int i)
From source file:skyc.ViewContent.java
private static String toBrowserHexValue(int number) { StringBuilder builder = new StringBuilder(Integer.toHexString(number & 0xff)); while (builder.length() < 2) { builder.append("0"); }//from ww w. ja v a 2 s . c o m return builder.toString().toUpperCase(); }
From source file:Main.java
public static String getColor24(int argbValue) { if (argbValue == -1) throw new IllegalArgumentException("This colorref is empty"); int bgrValue = argbValue & 0x00FFFFFF; int rgbValue = (bgrValue & 0x0000FF) << 16 | (bgrValue & 0x00FF00) | (bgrValue & 0xFF0000) >> 16; // http://www.w3.org/TR/REC-html40/types.html#h-6.5 switch (rgbValue) { case 0xFFFFFF: return "white"; case 0xC0C0C0: return "silver"; case 0x808080: return "gray"; case 0x000000: return "black"; case 0xFF0000: return "red"; case 0x800000: return "maroon"; case 0xFFFF00: return "yellow"; case 0x808000: return "olive"; case 0x00FF00: return "lime"; case 0x008000: return "green"; case 0x00FFFF: return "aqua"; case 0x008080: return "teal"; case 0x0000FF: return "blue"; case 0x000080: return "navy"; case 0xFF00FF: return "fuchsia"; case 0x800080: return "purple"; }/* www . j a va 2 s. c om*/ StringBuilder result = new StringBuilder("#"); String hex = Integer.toHexString(rgbValue); for (int i = hex.length(); i < 6; i++) { result.append('0'); } result.append(hex); return result.toString(); }
From source file:libepg.epg.util.datetime.BCD.java
public BCD(byte bcd) { high = bcd >>> 4;// w ww .j a v a 2 s . com low = bcd & 0x0f; Object[] parameters = null; CHECK: { if (!BCD_RANGE.contains(high)) { parameters = new Object[] { Integer.toHexString(bcd), "", Integer.toHexString(bcd) }; break CHECK; } if (!BCD_RANGE.contains(low)) { parameters = new Object[] { Integer.toHexString(bcd), "", Integer.toHexString(bcd) }; break CHECK; } } if (parameters != null) { MessageFormat msg = new MessageFormat( "??????????={0} ?={1} ?????={2}"); throw new IllegalArgumentException(msg.format(parameters)); } }
From source file:com.arpnetworking.metrics.proxy.models.messages.Command.java
/** * {@inheritDoc}//from w ww . j a v a2 s. co m */ @Override public String toString() { return MoreObjects.toStringHelper(this).add("id", Integer.toHexString(System.identityHashCode(this))) .add("class", this.getClass()).add("Command", _command).toString(); }
From source file:com.baidu.rigel.biplatform.cache.util.MacAddressUtil.java
/** * ??mac???mac?// ww w.ja v a 2 s .co m * @param ia * @throws SocketException * @throws UnknownHostException */ public static String getMacAddress(InetAddress ia) throws SocketException, UnknownHostException { if (ia == null) { ia = InetAddress.getLocalHost(); } //???? byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress(); StringBuffer sb = new StringBuffer(""); for (int i = 0; i < mac.length; i++) { if (i != 0) { sb.append("-"); } //? int temp = mac[i] & 0xff; String str = Integer.toHexString(temp).toUpperCase(); if (str.length() == 1) { sb.append("0" + str); } else { sb.append(str); } } return sb.toString(); }
From source file:com.myjeeva.spring.security.util.SpringExtensionsUtil.java
/** * generates the MD5 Hash value from given salt value * /*from w w w.j a v a2 s .com*/ * @param md5Salt - a {@link java.lang.String} object. * @return md5 hash value if success, <code>null</code> if exception/fails */ public static String getMD5(String md5Salt) { try { MessageDigest md = MessageDigest.getInstance(MD5); byte[] array = md.digest(md5Salt.getBytes(UTF8)); StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); } return sb.toString(); } catch (java.security.NoSuchAlgorithmException e) { LOG.error(e.getMessage()); } catch (UnsupportedEncodingException e) { LOG.error(e.getMessage()); } return null; }
From source file:com.autentia.bcbp.elements.SecurityItems.java
public SecurityItems(String typeOfData, String securityData) { super();//from w w w . j a va 2 s .c om String hexadecimalLength = Integer.toHexString(securityData.length()).toUpperCase(); this.beginningOfSecurityData = new Item("^", beginningOfSecurityDataLength, 25, PaddingType.String); this.typeOfData = new Item(typeOfData, typeOfDataLength, 28, PaddingType.String); this.variableSize = new Item(hexadecimalLength, variableSizeLength, 29, PaddingType.Number); this.securityData = new Item(securityData, securityData.length(), 30, PaddingType.String); }
From source file:com.dhbwloerrach.dhbwcampusapp20.codebutler.farebot.card.desfire.DesfireFileSettings.java
public static DesfireFileSettings Create(byte[] data) throws DesfireException { byte fileType = (byte) data[0]; ByteArrayInputStream stream = new ByteArrayInputStream(data); if (fileType == STANDARD_DATA_FILE || fileType == BACKUP_DATA_FILE) return new StandardDesfireFileSettings(stream); else if (fileType == LINEAR_RECORD_FILE || fileType == CYCLIC_RECORD_FILE) return new RecordDesfireFileSettings(stream); else if (fileType == VALUE_FILE) return new ValueDesfireFileSettings(stream); else/*from w w w .j a v a 2 s . c o m*/ throw new DesfireException("Unknown file type: " + Integer.toHexString(fileType)); }
From source file:Main.java
/** * Loads an {@link Interpolator} object from a resource * * @param context Application context used to access resources * @param id The resource id of the animation to load * @return The animation object reference by the specified id * @throws NotFoundException//w w w .j a va 2s .co m */ @SuppressWarnings("TryWithIdenticalCatches") public static Interpolator loadInterpolator(Context context, int id) throws NotFoundException { XmlResourceParser parser = null; try { parser = context.getResources().getAnimation(id); return createInterpolatorFromXml(context, parser); } catch (XmlPullParserException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } catch (IOException ex) { NotFoundException rnf = new NotFoundException( "Can't load animation resource ID #0x" + Integer.toHexString(id)); rnf.initCause(ex); throw rnf; } finally { if (parser != null) parser.close(); } }
From source file:gov.nasa.ensemble.common.ERGBUtils.java
/** * Converts rgb to hex/*from w w w . ja va 2s . c o m*/ * @param rgb to convert * @return hex string representation */ public static String formatERGB(ERGB rgb) { int intRGB = rgb.red; intRGB = intRGB * 256 + rgb.green; intRGB = intRGB * 256 + rgb.blue; String hexString = Integer.toHexString(intRGB); // Ensure this is 6 digits return "000000".substring(hexString.length()) + hexString; }