List of usage examples for java.lang Character Character
@Deprecated(since = "9") public Character(char value)
From source file:net.sf.jrf.domain.PersistentObjectDynaProperty.java
/** Gets default value. * @return default value.//from www . java 2 s .c om */ public Object getDefaultValue() { if (defaultValue != null) return this.defaultValue; Class cls = getType(); if (primitiveWrapperClass != null) { if (cls.equals(Boolean.TYPE)) return new Boolean(false); else if (cls.equals(Byte.TYPE)) return new Byte((byte) 0); else if (cls.equals(Character.TYPE)) return new Character((char) 0); else if (cls.equals(Double.TYPE)) return new Double((double) 0); else if (cls.equals(Float.TYPE)) return new Float((float) 0); else if (cls.equals(Integer.TYPE)) return new Integer((int) 0); else if (cls.equals(Long.TYPE)) return new Long((long) 0); else if (cls.equals(Short.TYPE)) return new Short((short) 0); else return null; } else return null; }
From source file:com.redhat.rhn.common.util.StringUtil.java
/** * Finds end of URL.//from w w w .j a va 2 s .co m * @param entireToken input String (URL) * @return position of last char of URL, returns -1 when entire String is URL */ private static int findEndOfUrl(String entireToken) { int space = entireToken.indexOf(' '); int line = entireToken.indexOf("<br/>"); int tag = entireToken.indexOf("<"); int end = -1; // end characters Set<Character> endChars = new HashSet<Character>(); endChars.add(new Character('.')); endChars.add(new Character(',')); if (space == -1 || (space > line && line != -1)) { end = line; } else { end = space; } if (end == -1 || (end > tag && tag != -1)) { end = tag; } // dot before the end if (end > 0 && (endChars.contains(new Character(entireToken.charAt(end - 1))))) { end--; } // dot at the end else if (endChars.contains(new Character(entireToken.charAt(entireToken.length() - 1)))) { end = entireToken.length() - 1; } return end; }
From source file:com.tc.object.ApplicatorDNAEncodingTest.java
public void testBasic() throws Exception { final TCByteBufferOutputStream output = new TCByteBufferOutputStream(); final List<Object> data = new ArrayList<Object>(); data.add(new ObjectID(1)); data.add("one"); data.add(new Boolean(true)); data.add("two"); data.add(new Byte((byte) 42)); data.add("three"); data.add(new Character('\t')); data.add("four"); data.add(new Double(Math.PI)); data.add("five"); data.add(new Float(Math.E)); data.add("six"); data.add(new Integer(Integer.MAX_VALUE)); data.add("seven"); data.add(new Long(System.currentTimeMillis() % 17)); data.add("eight"); data.add(new Short((short) -1)); final DNAEncoding encoding = getApplicatorEncoding(); for (Object d : data) { encoding.encode(d, output);/*from w w w.j a v a 2 s .c o m*/ } final TCByteBufferInputStream input = new TCByteBufferInputStream(output.toArray()); for (Object orig : data) { final Object decoded = encoding.decode(input); assertEquals(orig, decoded); } assertEquals(0, input.available()); }
From source file:org.dragonet.net.translator.Translator_v0_11.java
public void processCrafting(WindowSetSlotPacket packet) { if (!(this.getSession().getPlayer() instanceof Player)) { return;// ww w . jav a2 s .c om } int realSlot = 0; if (packet.slot < 27) { realSlot = packet.slot + 9; } else if (packet.slot >= 27) { realSlot = packet.slot - 27; } ItemStack item = this.getSession().getPlayer().getInventory().getItem(realSlot); if (item == null) { item = new ItemStack(Material.AIR); } else if (item.getAmount() <= 0) { this.getSession().getPlayer().getInventory().setItem(realSlot, null); return; } System.out.println( "FROM " + item.toString() + "to (ITEM=" + packet.item.id + ",CNT=" + packet.item.count + ")"); if (packet.item.count < 0) { this.getSession().sendInventory(); return; } if (item.getTypeId() == 0 && packet.item.id == 0) { this.getSession().sendInventory(); return; //No changes } if (item.getTypeId() == packet.item.id && item.getAmount() == packet.item.count && item.getDurability() == packet.item.meta) { this.getSession().sendInventory(); return; //No changes } if ((item.getTypeId() != 0 && packet.item.id == 0) || (item.getTypeId() != 0 && (item.getTypeId() != packet.item.id)) || (item.getAmount() > (packet.item.count & 0xFF))) { this.getSession().sendInventory(); return; //Decreasing item, ignore } int amount = packet.item.count - (item.getTypeId() == 0 ? 0 : item.getAmount()); ItemStack result = new ItemStack(packet.item.id, amount, packet.item.meta); List<Recipe> recipes = this.getSession().getServer().getCraftingManager().getRecipesFor(result); if (recipes.size() <= 0) { return; } //System.out.println("CRAFTING FOR: " + result.toString() + ", recipes count: " + recipes.size()); if (packet.windowID == PEWindowConstantID.PLAYER_INVENTORY && recipes.size() > 4) { //Can not craft more than 4 recipes in a player inventory this.getSession().sendInventory(); return; } ItemList items = new ItemList(this.getSession().getPlayer().getInventory()); //List all ways to craft for (Recipe recipe : recipes) { if (recipe instanceof ShapedRecipe) { ShapedRecipe shaped = (ShapedRecipe) recipe; boolean faild = false; for (String itemChar : shaped.getShape()) { ItemStack ingredient = shaped.getIngredientMap().get(new Character(itemChar.charAt(0))); if (ingredient == null) { continue; } if (!items.tryToRemove(ingredient)) { faild = true; break; } } if (!faild) { //Apply changes for (String itemChar : shaped.getShape()) { ItemStack ingredient = shaped.getIngredientMap().get(new Character(itemChar.charAt(0))); if (ingredient == null) { continue; } this.getSession().getPlayer().getInventory().remove(ingredient); } //System.out.println("CRAFT SUCCESS! "); } else { continue; } this.getSession().getPlayer().getInventory().addItem(result); this.getSession().sendInventory(); return; } } //System.out.println("FAILD TO CRAFT! "); this.getSession().sendInventory(); }
From source file:jp.terasoluna.fw.validation.FieldChecksTest01.java
/** * testExtractValue07()/*ww w . j a v a 2s . co m*/ * <br><br> * * () * <br> * F * <br><br> * () bean:new Character('@')<br> * * <br> * () String:"@"<br> * * <br> * ?bean?Character???bean???????? * <br> * * @throws Exception ????? */ @Test public void testExtractValue07() throws Exception { // // assertEquals("@", new FieldChecks().extractValue(new Character('@'), field)); }
From source file:com.sfs.jbtimporter.JBTProcessor.java
/** * Gets the special character map./*from ww w. j a v a 2 s .c om*/ * * @return the special character map */ private final Map<Character, String> initialiseSpecialCharacterMap() { final Map<Character, String> map = new HashMap<Character, String>(); map.put(new Character('\u0100'), "Ā"); map.put(new Character('\u0101'), "ā"); map.put(new Character('\u0102'), "Ă"); map.put(new Character('\u0103'), "ă"); map.put(new Character('\u0104'), "Ą"); map.put(new Character('\u0105'), "ą"); map.put(new Character('\u0106'), "Ć"); map.put(new Character('\u0107'), "ć"); map.put(new Character('\u0108'), "Ĉ"); map.put(new Character('\u0108'), "ĉ"); map.put(new Character('\u010C'), "Č"); map.put(new Character('\u010D'), "č"); map.put(new Character('\u010E'), "Ď"); map.put(new Character('\u010F'), "ď"); map.put(new Character('\u0110'), "Đ"); map.put(new Character('\u0111'), "đ"); map.put(new Character('\u0112'), "Ē"); map.put(new Character('\u0113'), "ē"); map.put(new Character('\u0118'), "Ę"); map.put(new Character('\u0119'), "ę"); map.put(new Character('\u011A'), "Ě"); map.put(new Character('\u011B'), "ě"); map.put(new Character('\u011C'), "Ĝ"); map.put(new Character('\u011D'), "ĝ"); map.put(new Character('\u011E'), "Ğ"); map.put(new Character('\u011F'), "ğ"); map.put(new Character('\u0122'), "Ģ"); map.put(new Character('\u0123'), "ģ"); map.put(new Character('\u0124'), "Ĥ"); map.put(new Character('\u0125'), "ĥ"); map.put(new Character('\u012A'), "Ī"); map.put(new Character('\u012B'), "ī"); map.put(new Character('\u0130'), "İ"); map.put(new Character('\u0131'), "ı"); map.put(new Character('\u0134'), "Ĵ"); map.put(new Character('\u0135'), "ĵ"); map.put(new Character('\u0136'), "Ķ"); map.put(new Character('\u0137'), "ķ"); map.put(new Character('\u0139'), "Ĺ"); map.put(new Character('\u013A'), "ĺ"); map.put(new Character('\u013B'), "Ļ"); map.put(new Character('\u013C'), "ļ"); map.put(new Character('\u013D'), "Ľ"); map.put(new Character('\u013E'), "ľ"); map.put(new Character('\u0141'), "Ł"); map.put(new Character('\u0142'), "ł"); map.put(new Character('\u0143'), "Ń"); map.put(new Character('\u0144'), "ń"); map.put(new Character('\u0145'), "Ņ"); map.put(new Character('\u0146'), "ņ"); map.put(new Character('\u0147'), "Ň"); map.put(new Character('\u0148'), "ň"); map.put(new Character('\u0150'), "Ő"); map.put(new Character('\u0151'), "ő"); map.put(new Character('\u0154'), "Ŕ"); map.put(new Character('\u0155'), "ŕ"); map.put(new Character('\u0156'), "Ŗ"); map.put(new Character('\u0157'), "ŗ"); map.put(new Character('\u0158'), "Ř"); map.put(new Character('\u0159'), "ř"); map.put(new Character('\u015A'), "Ś"); map.put(new Character('\u015B'), "ś"); map.put(new Character('\u015C'), "Ŝ"); map.put(new Character('\u015D'), "ŝ"); map.put(new Character('\u015E'), "Ş"); map.put(new Character('\u015F'), "ş"); map.put(new Character('\u0160'), "Š"); map.put(new Character('\u0161'), "š"); map.put(new Character('\u0162'), "Ţ"); map.put(new Character('\u0163'), "ţ"); map.put(new Character('\u0164'), "Ť"); map.put(new Character('\u0165'), "ť"); map.put(new Character('\u016A'), "Ū"); map.put(new Character('\u016B'), "ū"); map.put(new Character('\u016C'), "Ŭ"); map.put(new Character('\u016D'), "ŭ"); map.put(new Character('\u016E'), "Ů"); map.put(new Character('\u016F'), "ů"); map.put(new Character('\u0170'), "Ű"); map.put(new Character('\u0171'), "ű"); map.put(new Character('\u0178'), "Ÿ"); map.put(new Character('\u0179'), "Ź"); map.put(new Character('\u017A'), "ź"); map.put(new Character('\u017B'), "Ż"); map.put(new Character('\u017C'), "ż"); map.put(new Character('\u017D'), "Ž"); map.put(new Character('\u017E'), "ž"); map.put(new Character('\u2116'), "№"); map.put(new Character('\u00C1'), "Á"); map.put(new Character('\u00E1'), "á"); map.put(new Character('\u00C2'), "Â"); map.put(new Character('\u00E2'), "â"); map.put(new Character('\u00C6'), "Æ"); map.put(new Character('\u00E6'), "æ"); map.put(new Character('\u00E0'), "à"); map.put(new Character('\u00C0'), "À"); map.put(new Character('\u00C5'), "Å"); map.put(new Character('\u00E5'), "å"); map.put(new Character('\u00C3'), "Ã"); map.put(new Character('\u00E3'), "ã"); map.put(new Character('\u00C4'), "Ä"); map.put(new Character('\u00E4'), "ä"); map.put(new Character('\u2022'), "•"); map.put(new Character('\u00C7'), "Ç"); map.put(new Character('\u00E7'), "ç"); map.put(new Character('\u00A9'), "©"); map.put(new Character('\u2020'), "†"); map.put(new Character('\u00B0'), "°"); map.put(new Character('\u00C9'), "É"); map.put(new Character('\u00E9'), "é"); map.put(new Character('\u00CA'), "Ê"); map.put(new Character('\u00EA'), "ê"); map.put(new Character('\u00C8'), "È"); map.put(new Character('\u00E8'), "è"); map.put(new Character('\u00D0'), "Ð"); map.put(new Character('\u00F0'), "ð"); map.put(new Character('\u00CB'), "Ë"); map.put(new Character('\u00EB'), "ë"); map.put(new Character('\u20AC'), "€"); map.put(new Character('\u00CD'), "Í"); map.put(new Character('\u00ED'), "í"); map.put(new Character('\u00CE'), "Î"); map.put(new Character('\u00EE'), "î"); map.put(new Character('\u00A1'), "¡"); map.put(new Character('\u00CC'), "Ì"); map.put(new Character('\u00EC'), "ì"); map.put(new Character('\u00BF'), "¿"); map.put(new Character('\u00CF'), "Ï"); map.put(new Character('\u00EF'), "ï"); map.put(new Character('\u00AB'), "«"); map.put(new Character('\u2014'), "—"); map.put(new Character('\u00B5'), "µ"); map.put(new Character('\u00B7'), "·"); map.put(new Character('\u2013'), "–"); map.put(new Character('\u00D1'), "Ñ"); map.put(new Character('\u00F1'), "ñ"); map.put(new Character('\u00D3'), "Ó"); map.put(new Character('\u00F3'), "ó"); map.put(new Character('\u00D4'), "Ô"); map.put(new Character('\u00F4'), "ô"); map.put(new Character('\u0152'), "Œ"); map.put(new Character('\u0153'), "œ"); map.put(new Character('\u00D2'), "Ò"); map.put(new Character('\u00F2'), "ò"); map.put(new Character('\u00AA'), "ª"); map.put(new Character('\u00BA'), "º"); map.put(new Character('\u00D8'), "Ø"); map.put(new Character('\u00F8'), "ø"); map.put(new Character('\u00D5'), "Õ"); map.put(new Character('\u00F5'), "õ"); map.put(new Character('\u00D6'), "Ö"); map.put(new Character('\u00F6'), "ö"); map.put(new Character('\u00A3'), "£"); map.put(new Character('\u00BB'), "»"); map.put(new Character('\u00AE'), "®"); map.put(new Character('\u00DF'), "ß"); map.put(new Character('\u00DE'), "Þ"); map.put(new Character('\u00FE'), "þ"); map.put(new Character('\u00DA'), "Ú"); map.put(new Character('\u00FA'), "ú"); map.put(new Character('\u00DB'), "Û"); map.put(new Character('\u00FB'), "û"); map.put(new Character('\u00D9'), "Ù"); map.put(new Character('\u00F9'), "ù"); map.put(new Character('\u00F6'), "¨"); map.put(new Character('\u00DC'), "Ü"); map.put(new Character('\u00FC'), "ü"); map.put(new Character('\u00DD'), "Ý"); map.put(new Character('\u00FD'), "ý"); map.put(new Character('\u00FF'), "ÿ"); return map; }
From source file:net.sf.ezmorph.bean.BeanMorpherTest.java
public void testMorph_PrimitiveBean_to_TypedBean() { PrimitiveBean primitiveBean = new PrimitiveBean(); primitiveBean.setPclass(Object.class); primitiveBean.setPstring("MORPH"); morpherRegistry.registerMorpher(new BeanMorpher(TypedBean.class, morpherRegistry)); TypedBean typedBean = (TypedBean) morpherRegistry.morph(TypedBean.class, primitiveBean); assertNotNull(typedBean);/*from ww w . ja v a2s .c o m*/ assertEquals(Boolean.FALSE, typedBean.getPboolean()); assertEquals(Byte.valueOf("0"), typedBean.getPbyte()); assertEquals(Short.valueOf("0"), typedBean.getPshort()); assertEquals(Integer.valueOf("0"), typedBean.getPint()); assertEquals(Long.valueOf("0"), typedBean.getPlong()); assertEquals(Float.valueOf("0"), typedBean.getPfloat()); assertEquals(Double.valueOf("0"), typedBean.getPdouble()); assertEquals(new Character('\0'), typedBean.getPchar()); assertEquals(null, typedBean.getParray()); assertEquals(null, typedBean.getPlist()); assertEquals(null, typedBean.getPbean()); assertEquals(null, typedBean.getPmap()); assertEquals("MORPH", typedBean.getPstring()); assertEquals(Object.class, typedBean.getPclass()); }
From source file:edu.cornell.mannlib.vedit.util.Stemmer.java
public static String StemString(String inputStr, int maxLength) { String outputStr = ""; int previousCh = 0; char[] w = new char[maxLength]; char[] inputArray = inputStr.toCharArray(); Stemmer s = new Stemmer(); int inputArrayIndex = 0, stemmerInputBufferIndex = 0, ch = 0; for (inputArrayIndex = 0; inputArrayIndex < inputArray.length; inputArrayIndex++) { ch = inputArray[inputArrayIndex]; if (Character.isLetter((char) ch)) { stemmerInputBufferIndex = 0; // start collecting letters for a new word while (inputArrayIndex < inputArray.length) { // keep reading until hit character other than a letter ch = Character.toLowerCase((char) ch); w[stemmerInputBufferIndex] = (char) ch; if (stemmerInputBufferIndex < maxLength - 1) { stemmerInputBufferIndex++; }/*from w w w . j a v a 2s . co m*/ if (inputArrayIndex < inputArray.length - 1) { previousCh = ch; ch = inputArray[++inputArrayIndex]; if (!Character.isLetter((char) ch)) { // parse the word in preparation for starting a new one for (int c = 0; c < stemmerInputBufferIndex; c++) { // copy to stemmer internal buffer s.add(w[c]); } s.stem(); { String u; u = s.toString(); outputStr += u; if (ch == '-') { // replace - with space outputStr += " "; } else if (ch == '.') { if (Character.isDigit((char) previousCh)) { outputStr += "."; } else { outputStr += " "; //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass } } else { Character Ch = new Character((char) ch); outputStr += Ch.toString(); } stemmerInputBufferIndex = 0; // to avoid repeats after ) } break; } } else { break; } } } else if (Character.isWhitespace((char) ch)) { if (!Character.isWhitespace((char) previousCh)) { if (previousCh != '.') { Character Ch = new Character((char) ch); outputStr += Ch.toString(); } } } else if (ch == '(') { // open paren; copy all characters until close paren while (ch != ')') { if (inputArrayIndex < inputArray.length) { ch = inputArray[inputArrayIndex++]; } else { log.trace(""); log.trace("1 short of EOS in paren at pos: " + inputArrayIndex + " of " + inputStr); break; } Character Ch = new Character((char) ch); //outputStr += Ch.toString(); //System.out.print( Ch.toString() ); } //log.trace(""); /* not needed -- just duplicates close paren if ( ch == ')') { Character Ch = new Character((char) ch); outputStr += Ch.toString(); log.trace( Ch.toString() ); } */ stemmerInputBufferIndex = 0; } else if (ch == ')') { // when is last character of input string Character Ch = new Character((char) ch); outputStr += Ch.toString(); log.trace(Ch.toString()); log.trace("found close paren at position: " + inputArrayIndex + " of input term " + inputStr); } else if (ch == '-') { // replace - with space outputStr += " "; } else if (ch == '.') { if (Character.isDigit((char) previousCh)) { outputStr += "."; } else { outputStr += " "; //previousCh = 32; // set to whitespace; extra spaces should be filtered out on next pass } } else { Character Ch = new Character((char) ch); outputStr += Ch.toString(); } previousCh = ch; if (ch < 0) break; } if (stemmerInputBufferIndex > 0) { for (int c = 0; c < stemmerInputBufferIndex; c++) { s.add(w[c]); } s.stem(); String u; u = s.toString(); outputStr += u; } return outputStr == null ? (outputStr.equals("") ? null : outputStr.trim()) : outputStr.trim(); }
From source file:org.apache.geode.management.internal.cli.util.JsonUtil.java
public static Object getPrimitiveOrWrapperValue(Class<?> klass, Object value) throws IllegalArgumentException { if (klass.isAssignableFrom(Byte.class) || klass.isAssignableFrom(byte.class)) { return value; } else if (klass.isAssignableFrom(Short.class) || klass.isAssignableFrom(short.class)) { return value; } else if (klass.isAssignableFrom(Integer.class) || klass.isAssignableFrom(int.class)) { return value; } else if (klass.isAssignableFrom(Long.class) || klass.isAssignableFrom(long.class)) { return value; } else if (klass.isAssignableFrom(Float.class) || klass.isAssignableFrom(float.class)) { return value; } else if (klass.isAssignableFrom(Double.class) || klass.isAssignableFrom(double.class)) { return value; } else if (klass.isAssignableFrom(Boolean.class) || klass.isAssignableFrom(boolean.class)) { return value; } else if (klass.isAssignableFrom(String.class)) { return String.valueOf(value); } else if (klass.isAssignableFrom(Character.class)) { // Need to take care of converting between string to char values if (value instanceof String) { String str = (String) value; if (str.length() == 1) return new Character(str.charAt(0)); else if (str.length() > 1 || str.length() == 0) { throw new IllegalArgumentException( "Expected Character value but found String with length " + str.length()); }//from w w w .j av a2 s . c om } else if (value instanceof Character) { return value; } else { throw new IllegalArgumentException("Expected Character value but found " + value.getClass()); } } else if (klass.isAssignableFrom(char.class)) { // Need to take care of converting between string to char values if (value instanceof String) { String str = (String) value; if (str.length() == 1) return str.charAt(0); else if (str.length() > 1 || str.length() == 0) { throw new IllegalArgumentException( "Expected Character value but found String with length " + str.length()); } } else if (value instanceof Character) { return ((Character) value).charValue(); } else { throw new IllegalArgumentException("Expected Character value but found " + value.getClass()); } } else { return null; } return value; }
From source file:org.jboss.dashboard.ui.taglib.formatter.Formatter.java
/** * Sets a parameter for the fragment. The object set as parameter value * must not be changed during all the execution, otherwise the result won't be * as expected. That is, if this object has a method that changes its content, * this method must not be called by the Formatter during the service() method. * Otherwise, all the rendering performed by the fragmentValue tag will use * the *last* version of the object, the one existing after the invocation of * service method, which is probably not expected. * <p>Example, of a iterating formatter:</p> * <code>/*from www . j a va2 s. co m*/ * StringBuffer sb = new StringBuffer();<br> * for( int i= 0; i<10; i++){<br> * sb.delete(0,sb.length())<br> * sb.append( i );<br> * setAttribute("index",sb);<br> * renderFragment("output");<br> * }<br> * * </code> * will generate an output like : * 10 10 10 10 10 10 10 10 10 10 * while the expected output is: * 0 1 2 3 4 5 6 7 8 9 * <p/> * So, use objects and don't change them. This is usually easy to accomplish, by using * different instances, in the example above, replace sb.delete(0,sb.length()) with * sb = new StringBuffer(); * * @param name Name of the parameter. * @param value It's value. Must not be changed during all the execution. */ protected void setAttribute(String name, char value) { if (log.isDebugEnabled()) log.debug("Setting of attribute " + name + " scheduled."); tag.addProcessingInstruction(ProcessingInstruction.getSetParameterInstruction(name, new Character(value))); }