List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:com.nfwork.dbfound.json.JSONDynaBean.java
public Object get(String name) { Object value = dynaValues.get(name); if (value != null) { return value; }/*from w w w .jav a 2 s. c o m*/ Class type = getDynaProperty(name).getType(); if (type == null) { throw new NullPointerException("Unspecified property type for " + name); } if (!type.isPrimitive()) { return value; } if (type == Boolean.TYPE) { return Boolean.FALSE; } else if (type == Byte.TYPE) { return new Byte((byte) 0); } else if (type == Character.TYPE) { return new Character((char) 0); } else if (type == Short.TYPE) { return new Short((short) 0); } else if (type == Integer.TYPE) { return new Integer(0); } else if (type == Long.TYPE) { return new Long(0); } else if (type == Float.TYPE) { return new Float(0.0); } else if (type == Double.TYPE) { return new Double(0); } return null; }
From source file:test.gov.nih.nci.cacoresdk.domain.other.primarykey.CharacterKeyResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set/*from ww w . ja v a 2s . c om*/ * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { CharacterKey searchObject = new CharacterKey(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.primarykey.CharacterKey", searchObject); String id = ""; if (results != null && results.size() > 0) { CharacterKey obj = (CharacterKey) ((List) results).get(0); Character idVal = obj.getId(); id = new Character(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/CharacterKey/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("CharacterKey" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:org.istsms.util.Javabean2JSON.java
private static Object getPrimitive(Object value, String type) { Object arg = null;/*ww w . j a v a2 s .co m*/ if (type.equals("boolean") || type.equals("java.lang.Boolean")) { arg = new Boolean(value.toString()); } else if (type.equals("byte") || type.equals("java.lang.Byte")) { arg = new Byte(value.toString()); } else if (type.equals("char") || type.equals("java.lang.Character")) { arg = new Character((char) value.toString().getBytes()[0]); } else if (type.equals("double") || type.equals("java.lang.Double")) { arg = new Double(value.toString()); } else if (type.equals("float") || type.equals("java.lang.Float")) { arg = new Float(value.toString()); } else if (type.equals("int") || type.equals("java.lang.Integer")) { arg = new Integer(value.toString()); } else if (type.equals("long") || type.equals("java.lang.Long")) { arg = new Long(value.toString()); } else if (type.equals("short") || type.equals("java.lang.Short")) { arg = new Short(value.toString()); } else if (type.equals("java.lang.String")) { arg = value; } // else if (type.equals("java.util.Calendar")) { // java.util.Calendar c=java.util.Calendar.getInstance(); // c.setTime(new java.util.Date(Long.parseLong(value.toString()))); // arg=c; // } return arg; }
From source file:cn.org.once.cstack.cli.utils.UserUtils.java
public String changePassword() { String oldPassword, newPassword, newPassword2 = ""; if (authentificationUtils.getMap().isEmpty()) { log.log(Level.SEVERE, "You are not connected to CloudUnit host! Please use connect command"); statusCommand.setExitStatut(1);//from w w w . jav a2s.c o m return null; } if (fileUtils.isInFileExplorer()) { log.log(Level.SEVERE, "You are currently in a container file explorer. Please exit it with close-explorer command"); statusCommand.setExitStatut(1); return null; } try { log.log(Level.INFO, "Enter your old password : "); oldPassword = new ConsoleReader().readLine(new Character('*')); log.log(Level.INFO, "Enter your new password : "); newPassword = new ConsoleReader().readLine(new Character('*')); log.log(Level.INFO, "Please confirm your new password : "); newPassword2 = new ConsoleReader().readLine(new Character('*')); if (!newPassword2.equalsIgnoreCase(newPassword)) { log.log(Level.SEVERE, "The password confirmation is incorrect! Please retry!"); return null; } Map<String, String> parameters = new HashMap<>(); parameters.put("password", oldPassword); parameters.put("newPassword", newPassword); restUtils.sendPutCommand(authentificationUtils.finalHost + "/user/change-password", authentificationUtils.getMap(), parameters); log.log(Level.INFO, "Your password was successfully changed"); statusCommand.setExitStatut(0); } catch (ResourceAccessException e) { log.log(Level.SEVERE, "The CLI can't etablished connexion with host servers. Please try later or contact an admin"); statusCommand.setExitStatut(1); return null; } catch (Exception e) { statusCommand.setExitStatut(1); return null; } return null; }
From source file:test.gov.nih.nci.cacoresdk.domain.other.primarykey.CharacterPrimitiveKeyResourceTest.java
/** * Uses Nested Search Criteria for search * Verifies that the results are returned * Verifies size of the result set//from ww w.j av a 2s . com * Verifies that none of the attributes are null * * @throws Exception */ public void testGet() throws Exception { try { CharacterPrimitiveKey searchObject = new CharacterPrimitiveKey(); Collection results = getApplicationService() .search("gov.nih.nci.cacoresdk.domain.other.primarykey.CharacterPrimitiveKey", searchObject); String id = ""; if (results != null && results.size() > 0) { CharacterPrimitiveKey obj = (CharacterPrimitiveKey) ((List) results).get(0); Character idVal = obj.getId(); id = new Character(idVal).toString(); } else return; if (id.equals("")) return; String url = baseURL + "/rest/CharacterPrimitiveKey/" + id; WebClient client = WebClient.create(url); client.type("application/xml").accept("application/xml"); Response response = client.get(); if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) { InputStream is = (InputStream) response.getEntity(); org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false); org.jdom.Document jDoc = builder.build(is); assertEquals(jDoc.getRootElement().getName(), "response"); } else if (response.getStatus() != 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } File myFile = new File("CharacterPrimitiveKey" + "XML.xml"); System.out.println("writing data to file " + myFile.getAbsolutePath()); FileWriter myWriter = new FileWriter(myFile); BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity()))); String output; System.out.println("Output from Server .... \n"); while ((output = br.readLine()) != null) { myWriter.write(output); System.out.println(output); } myWriter.flush(); myWriter.close(); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:org.kordamp.ezmorph.object.CharacterObjectMorpher.java
public Object morph(Object value) { if (value == null) { if (isUseDefault()) { return defaultValue; } else {/* w ww . j a v a 2s. c om*/ throw new MorphException("value is null"); } } if (value instanceof Character) { return (Character) value; } else { String s = String.valueOf(value); if (s.length() > 0) { return new Character(s.charAt(0)); } else { if (isUseDefault()) { return defaultValue; } else { throw new MorphException("Can't morph value: " + value); } } } }
From source file:org.apache.tika.parser.csv.CSVSnifferTest.java
@Test public void testCSVBasic() throws Exception { List<CSVResult> results = sniff(DELIMITERS, CSV_BASIC, StandardCharsets.UTF_8); assertEquals(2, results.size());/*from w w w . j a va2 s . co m*/ assertEquals(new Character(','), results.get(0).getDelimiter()); results = sniff(DELIMITERS, TSV_BASIC, StandardCharsets.UTF_8); assertEquals(2, results.size()); assertEquals(new Character('\t'), results.get(0).getDelimiter()); }
From source file:org.inwiss.platform.common.util.ConvertUtil.java
/** * Converts list to string concatenating list elements with the delimiter. * Each element is additionally enclosed in <code>encloser</code> chars. * * @param list List to convert to string * @param delimiter Delimiter to put between elements * @param encloser Character to enclose each element * @return List members, delimited by specifed delimiter. Each element enclosed with specified character *///from ww w . ja va 2 s . c o m public static String convertListToString(List list, String delimiter, char encloser) { return convertListToString(list, delimiter, new Character(encloser)); }
From source file:com.redhat.rhn.common.util.CharacterMap.java
/** * Check to see if the map contains this character * @param charTest The character to test// w w w. j a v a 2s . c o m * @return true if the character is in the map, false otherwise */ public boolean containsKey(char charTest) { return innerMap.containsKey(new Character(charTest)); }
From source file:org.joda.primitives.collection.impl.AbstractTestCharCollection.java
public Character[] getOtherNonNullElements() { return new Character[] { new Character('S'), new Character('J'), new Character('C') }; }