Example usage for java.lang Character Character

List of usage examples for java.lang Character Character

Introduction

In this page you can find the example usage for java.lang Character Character.

Prototype

@Deprecated(since = "9")
public Character(char value) 

Source Link

Document

Constructs a newly allocated Character object that represents the specified char value.

Usage

From source file:net.sf.json.JSONDynaBean.java

/**
 * DOCUMENT ME!/*from  www .  j a  v  a  2 s.  c  o  m*/
 *
 * @param name DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
public Object get(String name) {
    Object value = dynaValues.get(name);

    if (value != null) {
        return value;
    }

    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:org.datanucleus.store.scalaris.fieldmanager.StoreFieldManager.java

public void storeCharField(int fieldNumber, char value) {
    if (!isStorable(fieldNumber)) {
        return;//from w  w w. j  a v  a 2  s  .  c om
    }

    AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(fieldNumber);
    String name = storeMgr.getNamingFactory().getColumnName(mmd, ColumnType.COLUMN);
    try {
        jsonobj.put(name, new Character(value));
    } catch (JSONException e) {
        throw new NucleusException(e.getMessage(), e);
    }
}

From source file:com.sm.query.utils.QueryUtils.java

public static Object getParamArg(Class<?> cl) {
    if (!cl.isPrimitive())
        return null;
    else if (boolean.class.equals(cl))
        return Boolean.FALSE;
    else if (byte.class.equals(cl))
        return new Byte((byte) 0);
    else if (short.class.equals(cl))
        return new Short((short) 0);
    else if (char.class.equals(cl))
        return new Character((char) 0);
    else if (int.class.equals(cl))
        return Integer.valueOf(0);
    else if (long.class.equals(cl))
        return Long.valueOf(0);
    else if (float.class.equals(cl))
        return Float.valueOf(0);
    else if (double.class.equals(cl))
        return Double.valueOf(0);
    else/*from w ww . j  av  a2  s  . c om*/
        throw new UnsupportedOperationException();
}

From source file:org.rifidi.edge.adapter.thingmagic.commands.ThingmagicGetTagListCommand.java

@Override
public void run() {
    String splitregex = "" + new Character((char) 0x0a);

    // Output will look like this:
    // Ox303512B1F1FF795511B64E38|1
    // String message = "SELECT id, antenna_id FROM tag_id WHERE "
    // + "protocol_id='EPC1' " + "set time_out=250;\r\n";

    String message = ThingMagicStringBuilder.getCommandString(timeout, EPC0, EPC1, GEN2, ISO180006B);

    try {//from  w w  w.j ava2s  .co  m
        ((ThingmagicReaderSession) this.sensorSession).sendMessage(new ByteMessage(message.getBytes()));
    } catch (IOException e) {
        e.printStackTrace();
    }

    ByteMessage incomingMessage;

    Set<TagReadEvent> events = new HashSet<TagReadEvent>();

    try {
        incomingMessage = ((ThingmagicReaderSession) this.sensorSession).receiveMessage();
        if (logger.isDebugEnabled()) {
            logger.debug("raw msg as string: " + new String(incomingMessage.message));
        }
        String incoming = new String(incomingMessage.message).trim();
        String[] tagString = incoming.split(splitregex);
        for (String i : tagString) {
            i = i.trim();
            if (!i.isEmpty()) {
                // remove the 0x from the tagID
                i = i.substring(2);
                TagReadEvent tre = this.parseThingmagicTagString(i);
                events.add(tre);
            }
        }

        ReadCycle cycle = new ReadCycle(events, reader.get(), System.currentTimeMillis());
        sensorSession.getSensor().send(cycle);

        //TODO send tags
        //template.send(destination, new ReadCycleMessageCreator(cycle));
    } catch (IOException e) {
        // e.printStackTrace();
    } catch (TimeoutException e) {
        // TODO Auto-generated catch block
        //e.printStackTrace();
    }
}

From source file:org.docx4j.fonts.fop.fonts.SingleByteFont.java

private char mapUnencodedChar(char ch) {
    if (this.unencodedCharacters != null) {
        UnencodedCharacter unencoded = (UnencodedCharacter) this.unencodedCharacters.get(new Character(ch));
        if (unencoded != null) {
            if (this.additionalEncodings == null) {
                this.additionalEncodings = new java.util.ArrayList();
            }//from www.jav a2 s . c o  m
            SimpleSingleByteEncoding encoding = null;
            char mappedStart = 0;
            int additionalsCount = this.additionalEncodings.size();
            for (int i = 0; i < additionalsCount; i++) {
                mappedStart += 256;
                encoding = getAdditionalEncoding(i);
                char alt = encoding.mapChar(ch);
                if (alt != 0) {
                    return (char) (mappedStart + alt);
                }
            }
            if (encoding != null && encoding.isFull()) {
                encoding = null;
            }
            if (encoding == null) {
                encoding = new SimpleSingleByteEncoding(
                        getFontName() + "EncodingSupp" + (additionalsCount + 1));
                this.additionalEncodings.add(encoding);
                mappedStart += 256;
            }
            return (char) (mappedStart + encoding.addCharacter(unencoded.getCharacter()));
        }
    }
    return 0;
}

From source file:org.jbpm.instantiation.FieldInstantiator.java

public static Object getValue(Class type, Element propertyElement) {
    // parse the value
    Object value = null;//  w w  w  .j ava2 s . c  om
    try {

        if (type == String.class) {
            value = propertyElement.getText();
        } else if ((type == Integer.class) || (type == int.class)) {
            value = new Integer(propertyElement.getTextTrim());
        } else if ((type == Long.class) || (type == long.class)) {
            value = new Long(propertyElement.getTextTrim());
        } else if ((type == Float.class) || (type == float.class)) {
            value = new Float(propertyElement.getTextTrim());
        } else if ((type == Double.class) || (type == double.class)) {
            value = new Double(propertyElement.getTextTrim());
        } else if ((type == Boolean.class) || (type == boolean.class)) {
            value = Boolean.valueOf(propertyElement.getTextTrim());
        } else if ((type == Character.class) || (type == char.class)) {
            value = new Character(propertyElement.getTextTrim().charAt(0));
        } else if ((type == Short.class) || (type == short.class)) {
            value = new Short(propertyElement.getTextTrim());
        } else if ((type == Byte.class) || (type == byte.class)) {
            value = new Byte(propertyElement.getTextTrim());
        } else if (List.class.isAssignableFrom(type)) {
            value = getCollection(propertyElement, new ArrayList());
        } else if (Set.class.isAssignableFrom(type)) {
            value = getCollection(propertyElement, new HashSet());
        } else if (Collection.class.isAssignableFrom(type)) {
            value = getCollection(propertyElement, new ArrayList());
        } else if (Map.class.isAssignableFrom(type)) {
            value = getMap(propertyElement, new HashMap());
        } else if (Element.class.isAssignableFrom(type)) {
            value = propertyElement;
        } else {
            Constructor constructor = type.getConstructor(new Class[] { String.class });
            if ((propertyElement.isTextOnly()) && (constructor != null)) {
                value = constructor.newInstance(new Object[] { propertyElement.getTextTrim() });
            }
        }
    } catch (Exception e) {
        log.error("couldn't parse the bean property value '" + propertyElement.asXML() + "' to a '"
                + type.getName() + "'");
        throw new JbpmException(e);
    }
    return value;
}

From source file:org.pdfsam.console.business.dto.commands.AbstractParsedCommand.java

public AbstractParsedCommand(boolean overwrite, boolean compress, char outputPdfVersion) {
    this.overwrite = overwrite;
    this.compress = compress;
    this.outputPdfVersion = new Character(outputPdfVersion);
}

From source file:com.jdom.word.playdough.presenter.GamePackPlayerPresenter.java

void updateSourceLetters(Jumble jumble) {
    List<Character> sourceLetters = jumble.getSourceLetters();
    String runningWord = jumble.getRunningWord();
    if (runningWord == null || StringUtils.isEmpty(runningWord)) {
        originalSourceLettersUsedMarkers = new boolean[sourceLetters.size()];
    }/* w w  w . j  a v a 2s. co  m*/

    String sourceWord = jumble.getSourceWord();
    int length = sourceWord.length();
    List<ButtonConfiguration> buttons = new ArrayList<ButtonConfiguration>(length);
    for (int i = 0; i < length; i++) {
        final int currentIndex = i;
        Character character = new Character(sourceWord.charAt(i));

        final String letter = new String("" + character).toUpperCase();
        boolean shouldBeEnabled = !originalSourceLettersUsedMarkers[i];

        Runnable clickAction = new Runnable() {
            public void run() {
                new Thread() {
                    final SoundHandler soundHandler = view.getSoundHandler();

                    @Override
                    public void run() {
                        if (!soundHandler.isMuted()) {
                            soundHandler.playButtonClick();
                        }
                    }
                }.start();

                addLetterToRunningWord(currentIndex, letter.charAt(0));
            }
        };

        ButtonConfiguration button = new ButtonConfiguration(letter, currentIndex, shouldBeEnabled,
                clickAction);
        buttons.add(button);
    }

    view.updateSourceLetters(buttons);
}

From source file:org.trianacode.taskgraph.ser.ObjectMarshaller.java

public static Object getPrimitive(String name, String value) {
    if (name.equals("boolean") || name.equals("java.lang.Boolean")) {
        return new Boolean(value);
    } else if (name.equals("int") || name.equals("java.lang.Integer")) {
        return new Integer(value);
    } else if (name.equals("short") || name.equals("java.lang.Short")) {
        return new Short(value);
    } else if (name.equals("char") || name.equals("java.lang.Character")) {
        return new Character(value.charAt(0));
    } else if (name.equals("long") || name.equals("java.lang.Long")) {
        return new Long(value);
    } else if (name.equals("double") || name.equals("java.lang.Double")) {
        return new Double(value);
    } else if (name.equals("float") || name.equals("java.lang.Float")) {
        return new Float(value);
    }/* w  w w .  j a v a2  s  .  co m*/
    return value;
}

From source file:com.krawler.portal.util.StringUtil.java

public static boolean endsWith(String s, char end) {
    return endsWith(s, (new Character(end)).toString());
}