List of usage examples for java.lang Integer Integer
@Deprecated(since = "9") public Integer(String s) throws NumberFormatException
From source file:org.workin.http.httpclient.v4.handler.response.IntegerResponseHandler.java
@Override public Integer handleResponse(HttpResponse response) throws ClientProtocolException, IOException { String result = super.doResponse(response); if (result != null) return new Integer(result); String defaultValue = super.getDefaultValue(); return StringUtils.isNotBlank(defaultValue) ? new Integer(defaultValue) : null; }
From source file:com.ewcms.publication.freemarker.directive.IncludeDirectiveTest.java
@Test public void testGetUniqueTemplatePath() { IncludeDirective directive = new IncludeDirective(null, null); String path = "/home/test.html"; Integer siteId = new Integer(2); String uPath = directive.getUniqueTemplatePath(siteId, path); Assert.assertEquals("2/home/test.html", uPath); path = "home/test.html"; uPath = directive.getUniqueTemplatePath(siteId, path); Assert.assertEquals("2/home/test.html", uPath); }
From source file:ScrollDesktop.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desk = new ScrollDesktop(); desk.setPreferredSize(new Dimension(1000, 1000)); getContentPane().add(new JScrollPane(desk), "Center"); JInternalFrame f1 = new JInternalFrame("Frame 1"); f1.getContentPane().add(new JLabel("This is frame f1")); f1.setResizable(true);/*from w w w .j a va 2 s . c om*/ f1.pack(); f1.setVisible(true); desk.add(f1, new Integer(10)); JInternalFrame f2 = new JInternalFrame("Frame 2"); f2.getContentPane().add(new JLabel("Content for f2")); f2.setResizable(true); f2.pack(); f2.setVisible(true); desk.add(f2, new Integer(20)); JInternalFrame f3 = new JInternalFrame("Frame 3"); f3.getContentPane().add(new JLabel("Content for f3")); f3.setResizable(true); f3.pack(); f3.setVisible(true); desk.add(f3, new Integer(20)); f3.toFront(); try { f3.setSelected(true); } catch (java.beans.PropertyVetoException ignored) { } pack(); setSize(300, 300); setVisible(true); }
From source file:com.hendisantika.pasien.domain.PasienIdGenerator.java
public Serializable generate(SessionImplementor session, Object object) throws HibernateException { String prefix = "PAS-"; // String prefix = "1500"; Connection connection = session.connection(); try {/* ww w .j a va2s . co m*/ PreparedStatement ps = connection .prepareStatement("SELECT MAX(pasien_id) as value from db_pasien.pasien2"); ResultSet rs = ps.executeQuery(); if (rs.next()) { int id = rs.getInt("value") + 1; // String id = rs.getString("value") + 1; String code = prefix + new Integer(id); // String code = prefix + id; // String code = prefix + StringUtils.leftPad("" + id, 3, '0'); System.out.println("Generated pasienId: " + code); return code; } } catch (SQLException e) { e.printStackTrace(); } return null; }
From source file:com.discursive.jccook.collections.typed.TypedMapExample.java
public void start() { // Make sure that items added to this variables = TypedMap.decorate(new HashMap(), String.class, Number.class); // Add two String objects variables.put("maxThreads", new Integer(200)); variables.put("minThreads", new Integer(20)); variables.put("lightSpeed", new Double(2.99792458e8)); // Try to add a String value try {// w w w . j ava2s . co m variables.put("server", "test.oreilly.com"); } catch (IllegalArgumentException iae) { System.out.println("Adding an String value Failed as expected"); } // Try to add an Integer key try { variables.put(new Integer(30), "test.oreilly.com"); } catch (IllegalArgumentException iae) { System.out.println("Adding an Integer key Failed as expected"); } // Now we can safely cast without the possibility of a ClassCastException Number reading = (Number) variables.get("lightSpeed"); }
From source file:com.diffeo.dossier.fc.StringCounterTest.java
@Test public void readOnlyAdd() { StringCounter name = new StringCounter(); name.add("John Smith", 1); assertThat(name.getStrings(), hasEntry("John Smith", new Integer(1))); name.add("John Smith", 1); assertThat(name.getStrings(), hasEntry("John Smith", new Integer(2))); name.setReadOnly(true);/*from w w w. j a va 2 s .co m*/ try { name.add("John Smith", 1); assertThat("UnsupportedOperationException", is("raised")); } catch (UnsupportedOperationException e) { } try { name.add("Big JS", 1); assertThat("UnsupportedOperationException", is("raised")); } catch (UnsupportedOperationException e) { } name.setReadOnly(false); name.add("John Smith", 2); assertThat(name.getStrings(), hasEntry("John Smith", new Integer(4))); assertThat(name.getStrings(), not(hasKey("Big JS"))); }
From source file:HTMLEncode.java
public static final String encode(String s, String cr) { if (entityTableEncode == null) { buildEntityTables();/*from w w w . j a va 2 s.co m*/ } if (s == null) { return ""; } StringBuffer sb = new StringBuffer(s.length() * 2); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch >= '?' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch == ' ') { sb.append(ch); continue; } if (ch == '\n') { sb.append(cr); continue; } String chEnc = encodeSingleChar(String.valueOf(ch)); if (chEnc != null) { sb.append(chEnc); } else { sb.append("&#"); sb.append((new Integer(ch)).toString()); sb.append(';'); } } return sb.toString(); }
From source file:com.yahoo.messenger.data.json.Error.java
public void unserializeJSON(JSONObject o) throws JSONException { // Mandatory fields setCode(new Integer(o.getInt("code"))); setDetail(o.getString("detail")); setDescription(o.getString("description")); }
From source file:Main.java
/** Transforms an array of primitives * to an array of Numbers./*from w w w. jav a2 s. co m*/ */ public static Number[] transformArray(int[] data) { Number[] n = new Number[data.length]; for (int i = 0; i < data.length; i++) n[i] = new Integer(data[i]); return n; }
From source file:com.basho.riak.pbc.mapreduce.MapReduceResponse.java
public MapReduceResponse(RpbMapRedResp resp, ByteString contentType2) { if (resp.hasPhase()) { this.phase = new Integer(resp.getPhase()); } else {// ww w .j a v a 2s . c o m this.phase = null; } if (resp.hasResponse()) { this.response = resp.getResponse(); } else { this.response = null; } this.contentType = contentType2; }