List of usage examples for java.lang Integer Integer
@Deprecated(since = "9") public Integer(String s) throws NumberFormatException
From source file:Main.java
public static int getIntegerProperty(Element properties, String name) { return new Integer( getPropertyNode(properties, name).getAttributes().getNamedItem(INTEGER_ATTR).getNodeValue()); }
From source file:Main.java
public static byte[] hexStringToBytes(String hex) { byte[] bytes = new byte[hex.length() / 2]; int j = 0;/*from w w w. j a va2 s. com*/ for (int i = 0; i < hex.length(); i += 2) { try { String hexByte = hex.substring(i, i + 2); Integer I = new Integer(0); I = Integer.decode("0x" + hexByte); int k = I.intValue(); bytes[j++] = new Integer(k).byteValue(); } catch (NumberFormatException e) { Log.d(LOG_TAG, "hexStringToBytes", e); return bytes; } catch (StringIndexOutOfBoundsException e) { Log.d(LOG_TAG, "hexStringToBytes", e); return bytes; } } return bytes; }
From source file:Main.java
static int getMinorVersionNumberInternal(String version) { if (!version.equals("@" + "version" + "@")) { try {/*from w w w . j a v a 2s . c o m*/ int firstDot = version.indexOf("."); String minusMajor = version.substring(firstDot + 1); int secondDot = minusMajor.indexOf("."); String minorStr = minusMajor.substring(0, secondDot); return new Integer(minorStr).intValue(); } catch (NumberFormatException nfe) { } } // in case this is a mainline version or NFE was caught (strange) return 7; }
From source file:Main.java
public static void showPercentToast(boolean show, Activity a, SharedPreferences prefs, double brightness) { if (percentToast == null) { percentToast = Toast.makeText(a, "", Toast.LENGTH_SHORT); }// w ww. java 2 s.co m percentToast.setText(new Integer((int) (brightness / 2.55)).toString() + "%"); if (show) { if (prefs.getBoolean("showToast", true)) percentToast.show(); } else { percentToast.cancel(); } }
From source file:Main.java
public static Hashtable<Character, Integer> createHashtable(String text) { Hashtable<Character, Integer> textHashTable = new Hashtable<Character, Integer>(); for (char c : text.toCharArray()) { if (textHashTable.get(c) != null) { Integer temp = textHashTable.get(c); textHashTable.put(c, temp + 1); } else {//w w w . j av a2 s . c o m textHashTable.put(c, new Integer(1)); } } return textHashTable; }
From source file:Main.java
public static Font getFontProperty(Element properties, String name) { String[] font = getPropertyNode(properties, name).getAttributes().getNamedItem(FONT_ATTR).getNodeValue() .split(","); return new Font(font[0], new Integer(font[1]), new Integer(font[2])); }
From source file:Main.java
public static Object wrapperClassCloner(Object value) { if (value instanceof Double) return new Double(((Double) value).doubleValue()); else if (value instanceof Float) return new Float(((Float) value).floatValue()); else if (value instanceof Long) return new Long(((Long) value).longValue()); else if (value instanceof Boolean) return new Boolean(((Boolean) value).booleanValue()); else if (value instanceof Integer) return new Integer(((Integer) value).intValue()); else// w w w .ja v a 2 s . com return null; }
From source file:Main.java
public static Color getColorProperty(Element properties, String name) { String[] rgb = getPropertyNode(properties, name).getAttributes().getNamedItem(COLOR_ATTR).getNodeValue() .split(","); return new Color(new Integer(rgb[0]), new Integer(rgb[1]), new Integer(rgb[2])); }
From source file:Main.java
static int getServiceVersionNumberInternal(String version) { if (!version.equals("@" + "version" + "@")) { try {//from ww w .j a v a 2s . c o m int firstDot = version.indexOf("."); int secondDot = version.indexOf(".", firstDot + 1); int p = secondDot + 1; int q = p; while (q < version.length() && Character.isDigit(version.charAt(q))) { q++; } if (p != q) { String service = version.substring(p, q); return new Integer(service).intValue(); } } catch (NumberFormatException nfe) { } } // in case this is a mainline version or NFE was caught (strange) return 0; }
From source file:Main.java
public static boolean write(String filename, Document document, boolean addDocType) { try {// ww w .j ava 2 s. c o m TransformerFactory tf = TransformerFactory.newInstance(); tf.setAttribute("indent-number", new Integer(4)); Transformer transformer = tf.newTransformer(); DOMSource source = new DOMSource(document); if (addDocType) { transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"); transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"); } transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.transform(source, new StreamResult(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename))))); return true; } catch (Exception e) { return false; } }