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:biz.taoconsulting.oxf.processor.converter.FromPdfConverter.java

private String MassageTextResult(String rawString) {
    // Removes unwanted characters
    // Currently we need to get rid of chr(13);
    String oldChar = new Character((char) 13).toString();
    return StringUtils.replace(rawString, oldChar, "");
    //return rawString.replace(oldChar, ""); // this only works with Java 5
}

From source file:com.meiah.core.util.StringUtil.java

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

From source file:org.openehr.build.RMObjectBuilder.java

private Object defaultValue(Class type) {
    if (type == boolean.class) {
        return Boolean.FALSE;
    } else if (type == double.class) {
        return new Double(0);
    } else if (type == float.class) {
        return new Float(0);
    } else if (type == int.class) {
        return new Integer(0);
    } else if (type == short.class) {
        return new Short((short) 0);
    } else if (type == long.class) {
        return new Long(0);
    } else if (type == char.class) {
        return new Character((char) 0);
    } else if (type == byte.class) {
        return new Byte((byte) 0);
    }/*from   w ww .  ja  va 2 s .  c o  m*/
    return null;
}

From source file:com.hihframework.core.utils.StringHelpers.java

/**
 * String >> char[] >> byte[] >> String
 * JSP.//  w  w  w . j  ava 2s. c o m
 *
 * @param source the source
 * @return the string
 */
public static String toByteString(final String source) {
    if (source == null) {
        return null;
    }

    if (source.length() == 0) {
        return "";
    }

    final char[] chars = source.toCharArray();
    final byte[] bytes = new byte[source.length() * 2];
    int index = 0;

    for (int i = 0, charValue = 0; (i < chars.length) && (index < (chars.length * 2)); i++) {
        charValue = chars[i];

        if (charValue > 255) {
            try {
                final byte[] tmp = (new Character(chars[i])).toString().getBytes("GB2312");

                for (int j = 0; j < tmp.length; j++) {
                    bytes[index] = tmp[j];
                    index++;
                }
            } catch (final Exception e) {
                e.printStackTrace();
            }
        } else {
            bytes[index] = (byte) chars[i];
            index++;
        }
    }

    return new String(bytes, 0, index);
}

From source file:TypeConversionHelper.java

/**
 * Convert the value to a instance of the given type. The value converted only
 * if the type can't be assigned from the current type of the value instance. 
 * @param value the value to be converted
 * @param type the type of the expected object returned from the coversion
 * @return the converted object, or null if the object can't be converted
 *//*from   ww  w . jav  a 2  s . c o m*/
public static Object convertTo(Object value, Class type) {
    //check if the id can be assigned for the field type, otherwise convert the id to the appropriate type
    if (!type.isAssignableFrom(value.getClass())) {
        if (type == short.class || type == Short.class) {
            return new Short(value.toString());
        } else if (type == char.class || type == Character.class) {
            return new Character(value.toString().charAt(0));
        } else if (type == int.class || type == Integer.class) {
            return new Integer(value.toString());
        } else if (type == long.class || type == Long.class) {
            return new Long(value.toString());
        } else if (type == boolean.class || type == Boolean.class) {
            return new Boolean(value.toString());
        } else if (type == byte.class || type == Byte.class) {
            return new Byte(value.toString());
        } else if (type == float.class || type == Float.class) {
            return new Float(value.toString());
        } else if (type == double.class || type == Double.class) {
            return new Double(value.toString());
        } else if (type == BigDecimal.class) {
            return new BigDecimal(value.toString());
        } else if (type == BigInteger.class) {
            return new BigInteger(value.toString());
        } else if (type == String.class) {
            return value.toString();
        } else {
            return null;
        }
    }
    return value;
}

From source file:org.vertx.java.http.eventbusbridge.integration.MessageSendWithReplyTest.java

@Test
public void testSendingCharacterXmlWithResponseXml() throws IOException {
    final EventBusMessageType messageType = EventBusMessageType.Character;
    final Character sentCharacter = new Character('T');
    int port = findFreePort();
    String responseUrl = createHttpServerUrl(port);
    Map<String, String> expectations = createExpectations("someaddress",
            Base64.encodeAsString(sentCharacter.toString()), messageType, responseUrl,
            MediaType.APPLICATION_XML);// w  w w.  j  a v  a  2  s  . c  om
    String responseBody = TemplateHelper.generateOutputUsingTemplate(SEND_RESPONSE_TEMPLATE_XML, expectations);
    createHttpServer(port, MediaType.APPLICATION_XML, responseBody);
    Handler<Message> messageConsumerHandler = new MessageSendWithReplyHandler(sentCharacter, expectations);
    vertx.eventBus().registerHandler(expectations.get("address"), messageConsumerHandler);
    String requestBody = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_XML, expectations);
    HttpRequestHelper.sendHttpPostRequest(url, requestBody, (VertxInternal) vertx,
            Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_XML);
}

From source file:org.celllife.idart.gui.patient.AddPatient.java

/**
 * This method initializes grpParticulars
 * /* w ww.j  av  a 2 s .c o  m*/
 */
private void createGrpParticulars() {

    int col2x = 105;

    // grpParticulars
    grpParticulars = new Group(compPatientInfo, SWT.NONE);
    grpParticulars.setBounds(new Rectangle(30, 40, 400, 255));
    grpParticulars.setText(Messages.getString("patient.group.particulars")); //$NON-NLS-1$
    grpParticulars.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    // Patient ID
    Label lblPatientId = new Label(grpParticulars, SWT.NONE);
    lblPatientId.setBounds(new Rectangle(7, 25, 84, 20));
    lblPatientId.setText(
            Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.patientid")); //$NON-NLS-1$ //$NON-NLS-2$
    lblPatientId.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    /*if(iDartProperties.country.equalsIgnoreCase("Nigeria")){
       txtPatientId = new CustomIdField(grpParticulars, SWT.BORDER);
        txtPatientId.setBounds(new Rectangle(col2x, 25, 270, 20));
    } else {
       txtPatientId = new TextAdapter(grpParticulars, SWT.BORDER);
       txtPatientId.setBounds(new Rectangle(col2x, 25, 150, 20));
    }*/
    txtPatientId = new TextAdapter(grpParticulars, SWT.BORDER);
    txtPatientId.setBounds(new Rectangle(col2x, 25, 150, 20));
    txtPatientId.setData(iDartProperties.SWTBOT_KEY, "txtPatientId"); //$NON-NLS-1$
    txtPatientId.setFocus();
    txtPatientId.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtPatientId.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if ((btnSearch != null) && (btnSearch.getEnabled())) {
                if ((e.character == SWT.CR)
                        || (e.character == (char) iDartProperties.intValueOfAlternativeBarcodeEndChar)) {
                    cmdSearchWidgetSelected();
                }
            }
        }
    });

    if (isAddnotUpdate) {
        txtPatientId.setEnabled(false);
    }

    btnSearch = new Button(grpParticulars, SWT.NONE);
    btnSearch.setBounds(new Rectangle(270, 20, 119, 28));
    /*if(iDartProperties.country.equalsIgnoreCase("Nigeria")){
       btnSearch.setBounds(new Rectangle(270, 47, 110, 28));
    } else {
       btnSearch.setBounds(new Rectangle(270, 20, 110, 28));
    }*/

    btnSearchByName = new Button(grpParticulars, SWT.NONE);
    btnSearchByName.setBounds(new Rectangle(270, 50, 119, 28));

    if (!isAddnotUpdate) {
        btnSearchByName.setVisible(false);
    }

    if (isAddnotUpdate) {
        btnSearch.setText(Messages.getString("patient.button.editid")); //$NON-NLS-1$
        btnSearch.setToolTipText(Messages.getString("patient.button.editid.tooltip")); //$NON-NLS-1$

        btnSearchByName.setText(Messages.getString("patient.button.editid.nome")); //$NON-NLS-1$
        btnSearchByName.setToolTipText(Messages.getString("patient.button.editid.tooltip.nome")); //$NON-NLS-1$
    } else {
        btnSearch.setText(Messages.getString("patient.button.search")); //$NON-NLS-1$
        btnSearch.setToolTipText(Messages.getString("patient.button.search.tooltip")); //$NON-NLS-1$
    }

    btnSearch.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnSearch.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            cmdSearchWidgetSelected();
        }
    });

    btnSearchByName.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnSearchByName.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            cmdSearchWidgetSelectedSearchByName();
        }
    });

    btnEkapaSearch = new Button(grpParticulars, SWT.NONE);
    btnEkapaSearch.setBounds(new Rectangle(270, 47, 110, 28));
    btnEkapaSearch.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnEkapaSearch.setText(Messages.getString("patient.button.ekapasearch")); //$NON-NLS-1$
    if (!iDartProperties.isEkapaVersion || isAddnotUpdate) {
        btnEkapaSearch.setVisible(false);
    }

    btnEkapaSearch.setToolTipText(Messages.getString("patient.button.ekapasearch.tooltip")); //$NON-NLS-1$
    btnEkapaSearch.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            cmdEkapaSearchWidgetSelected();
        }
    });

    // FirstNames
    Label lblFirstNames = new Label(grpParticulars, SWT.NONE);
    lblFirstNames.setBounds(new Rectangle(7, 55, 84, 20));
    lblFirstNames.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lblFirstNames.setText(
            Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.firstname")); //$NON-NLS-1$ //$NON-NLS-2$
    txtFirstNames = new Text(grpParticulars, SWT.BORDER);
    txtFirstNames.setBounds(new Rectangle(col2x, 55, 150, 20));
    txtFirstNames.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    // Surname
    Label lblSurname = new Label(grpParticulars, SWT.NONE);
    lblSurname.setBounds(new Rectangle(7, 85, 84, 20));
    lblSurname.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lblSurname.setText(
            Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.surname")); //$NON-NLS-1$ //$NON-NLS-2$
    txtSurname = new Text(grpParticulars, SWT.BORDER);
    txtSurname.setBounds(new Rectangle(col2x, 85, 150, 20));
    txtSurname.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    lblOtherPatientsWithThisID = new Label(grpParticulars, SWT.NONE);
    lblOtherPatientsWithThisID.setBounds(new Rectangle(355, 140, 40, 40));
    lblOtherPatientsWithThisID.setImage(ResourceUtils.getImage(iDartImage.PATIENTDUPLICATES_30X26));
    lblOtherPatientsWithThisID.setVisible(false);

    // Date of Birth
    Label lbldob = new Label(grpParticulars, SWT.NONE);
    lbldob.setBounds(new Rectangle(7, 115, 84, 20));
    lbldob.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lbldob.setText(Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.dob")); //$NON-NLS-1$ //$NON-NLS-2$

    cmbDOBDay = new Combo(grpParticulars, SWT.BORDER);
    cmbDOBDay.setBounds(new Rectangle(col2x, 112, 50, 18));
    cmbDOBDay.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbDOBDay.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    cmbDOBDay.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            String theText = cmbDOBDay.getText();
            if (cmbDOBDay.indexOf(theText) == -1) {
                cmbDOBDay.setText(cmbDOBDay.getItem(0));
            }
        }
    });

    cmbDOBMonth = new Combo(grpParticulars, SWT.BORDER);
    cmbDOBMonth.setBounds(new Rectangle(col2x + 50, 112, 97, 18));
    cmbDOBMonth.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbDOBMonth.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    cmbDOBMonth.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            String theText = cmbDOBMonth.getText();
            if (theText.length() > 2) {
                String s = theText.substring(0, 1);
                String t = theText.substring(1, theText.length());
                theText = s.toUpperCase() + t;
                String[] items = cmbDOBMonth.getItems();
                for (int i = 0; i < items.length; i++) {
                    if (items[i].substring(0, 3).equalsIgnoreCase(theText)) {
                        cmbDOBMonth.setText(items[i]);
                        cmbDOBYear.setFocus();
                    }
                }
            }
        }
    });

    cmbDOBYear = new Combo(grpParticulars, SWT.BORDER);
    cmbDOBYear.setBounds(new Rectangle(col2x + 148, 112, 60, 18));
    cmbDOBYear.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbDOBYear.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    cmbDOBYear.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            String theText = cmbDOBYear.getText();
            if ((cmbDOBYear.indexOf(theText) == -1) && (theText.length() >= 4)) {
                cmbDOBYear.setText(EMPTY);
            }
        }
    });

    cmbDOBDay.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            cmdUpdateAge();
        }
    });
    cmbDOBMonth.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            cmdUpdateAge();
        }
    });
    cmbDOBYear.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            cmdUpdateAge();
        }
    });

    // populate the comboboxes
    ComboUtils.populateDateCombos(cmbDOBDay, cmbDOBMonth, cmbDOBYear, false, false);
    cmbDOBDay.setVisibleItemCount(cmbDOBDay.getItemCount());
    cmbDOBMonth.setVisibleItemCount(cmbDOBMonth.getItemCount());
    cmbDOBYear.setVisibleItemCount(31);

    // Sex
    Label lblSex = new Label(grpParticulars, SWT.NONE);
    lblSex.setBounds(new Rectangle(7, 152, 84, 20));
    lblSex.setText(Messages.getString("patient.label.sex")); //$NON-NLS-1$
    lblSex.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    cmbSex = new Combo(grpParticulars, SWT.BORDER);
    cmbSex.setBounds(new Rectangle(col2x, 145, 150, 18));
    cmbSex.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    cmbSex.setBackground(ResourceUtils.getColor(iDartColor.WHITE));
    // cmbSex.setEditable(false);
    //cmbSex.add(Messages.getString("common.unknown")); //$NON-NLS-1$
    cmbSex.add(Messages.getString("patient.sex.female")); //$NON-NLS-1$
    cmbSex.add(Messages.getString("patient.sex.male")); //$NON-NLS-1$
    //cmbSex.setText(Messages.getString("common.unknown")); //$NON-NLS-1$
    cmbSex.select(0);
    cmbSex.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            e.doit = false;
            Character keyPressed = new Character(Character.toLowerCase(e.character));
            getLog().debug("The char pressed in cmbSex: " + keyPressed); //$NON-NLS-1$
            if (Character.isLetter(keyPressed)) {
                if (keyPressed.equals('f')) {
                    cmbSex.select(1);
                } else if (keyPressed.equals('m')) {
                    cmbSex.select(2);
                } else {
                    cmbSex.select(0);
                }
                updateClinicInfoTab();
            }
        }
    });

    /*
     * add TraverseListener to allow traversal out of combo see JavaDoc for
     * org.eclipse.swt.events.KeyEvent
     */
    cmbSex.addTraverseListener(new TraverseListener() {
        @Override
        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.doit = true;
            } else {
                e.doit = false;
            }
        }

    });
    cmbSex.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent se) {
            updateClinicInfoTab();
        }
    });

    // Age
    Label lblAge = new Label(grpParticulars, SWT.NONE);
    lblAge.setBounds(new Rectangle(col2x + 212, 117, 33, 20));
    lblAge.setText(Messages.getString("patient.label.age")); //$NON-NLS-1$
    lblAge.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtAge = new Text(grpParticulars, SWT.BORDER);
    txtAge.setBounds(new Rectangle(col2x + 249, 114, 35, 20));
    txtAge.setEditable(false);
    txtAge.setEnabled(false);
    txtAge.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));

    // Child Icon
    lblPicChild = new Label(grpParticulars, SWT.NONE);
    lblPicChild.setBounds(new Rectangle(255, 140, 50, 43));
    lblPicChild.setImage(ResourceUtils.getImage(iDartImage.CHILD_50X43));
    lblPicChild.setVisible(false);

    transito = new Button(grpParticulars, SWT.CHECK);
    transito.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 1, 1));
    transito.setBounds(new Rectangle(col2x, 150, 150, 18));
    transito.setText("Paciente Em Transito");
    transito.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    transito.setSelection(false);

    // Phone Cell
    Label lblPhoneCell = new Label(grpParticulars, SWT.NONE);
    lblPhoneCell.setBounds(new Rectangle(7, 207, 85, 20));
    lblPhoneCell.setText(Messages.getString("patient.label.cellphone")); //$NON-NLS-1$
    lblPhoneCell.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtCellphone = new Text(grpParticulars, SWT.BORDER);
    txtCellphone.setBounds(new Rectangle(col2x, 205, 150, 20));
    txtCellphone.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    txtCellphone.setEnabled(false);

    Label lblARVStartDate = new Label(grpParticulars, SWT.NONE);
    lblARVStartDate.setBounds(new Rectangle(7, 233, 90, 20));
    lblARVStartDate.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    lblARVStartDate.setText(Messages.getString("patient.label.arvstartdate")); //$NON-NLS-1$

    btnARVStart = new DateButton(grpParticulars, DateButton.ZERO_TIMESTAMP,
            new DateInputValidator(DateRuleFactory.beforeNowInclusive(true)));
    btnARVStart.setBounds(new Rectangle(col2x, 230, 150, 20));
    btnARVStart.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8));
    btnARVStart.setText(Messages.getString("common.unknown")); //$NON-NLS-1$

    btnPatientHistoryReport = new Button(grpParticulars, SWT.NONE);
    btnPatientHistoryReport.setBounds(new Rectangle(310, 140, 40, 40));
    btnPatientHistoryReport.setToolTipText(Messages.getString("patient.button.report.tooltip")); //$NON-NLS-1$
    btnPatientHistoryReport.setImage(ResourceUtils.getImage(iDartImage.REPORT_PATIENTHISTORY_30X26));

    btnPatientHistoryReport.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent mu) {
            cmdPatientHistoryWidgetSelected();
        }
    });

}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a <CODE>String</CODE> from the stream message.
 *
 * @return a Unicode string from the stream message
 * @throws JMSException//  w ww. j  av  a2s. c  om
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public String readString() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.NULL) {
            return null;
        }
        if (type == MarshallingSupport.BIG_STRING_TYPE) {
            return MarshallingSupport.readUTF8(dataIn);
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return this.dataIn.readUTF();
        }
        if (type == MarshallingSupport.LONG_TYPE) {
            return new Long(this.dataIn.readLong()).toString();
        }
        if (type == MarshallingSupport.INTEGER_TYPE) {
            return new Integer(this.dataIn.readInt()).toString();
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return new Short(this.dataIn.readShort()).toString();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return new Byte(this.dataIn.readByte()).toString();
        }
        if (type == MarshallingSupport.FLOAT_TYPE) {
            return new Float(this.dataIn.readFloat()).toString();
        }
        if (type == MarshallingSupport.DOUBLE_TYPE) {
            return new Double(this.dataIn.readDouble()).toString();
        }
        if (type == MarshallingSupport.BOOLEAN_TYPE) {
            return (this.dataIn.readBoolean() ? Boolean.TRUE : Boolean.FALSE).toString();
        }
        if (type == MarshallingSupport.CHAR_TYPE) {
            return new Character(this.dataIn.readChar()).toString();
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a String type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.opoo.oqs.core.AbstractQuery.java

public Query setCharacter(String name, char val) {
    setParameter(name, new Character(val), Type.CHARACTER);
    return this;
}

From source file:org.teiid.rhq.plugin.util.ProfileServiceUtil.java

public static SimpleValue wrap(MetaType type, String value) throws Exception {
    if (type instanceof SimpleMetaType) {
        SimpleMetaType st = (SimpleMetaType) type;

        if (SimpleMetaType.BIGDECIMAL.equals(st)) {
            return new SimpleValueSupport(st, new BigDecimal(value));
        } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
            return new SimpleValueSupport(st, new BigInteger(value));
        } else if (SimpleMetaType.BOOLEAN.equals(st)) {
            return new SimpleValueSupport(st, Boolean.valueOf(value));
        } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, Boolean.valueOf(value).booleanValue());
        } else if (SimpleMetaType.BYTE.equals(st)) {
            return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
        } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, value.getBytes()[0]);
        } else if (SimpleMetaType.CHARACTER.equals(st)) {
            return new SimpleValueSupport(st, new Character(value.charAt(0)));
        } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, value.charAt(0));
        } else if (SimpleMetaType.DATE.equals(st)) {
            try {
                return new SimpleValueSupport(st, SimpleDateFormat.getInstance().parse(value));
            } catch (ParseException e) {
                throw new Exception("Failed to convert value to SimpleValue", e); //$NON-NLS-1$
            }//ww w .j av  a 2  s  .co m
        } else if (SimpleMetaType.DOUBLE.equals(st)) {
            return new SimpleValueSupport(st, Double.valueOf(value));
        } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, Double.parseDouble(value));
        } else if (SimpleMetaType.FLOAT.equals(st)) {
            return new SimpleValueSupport(st, Float.parseFloat(value));
        } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, Float.valueOf(value));
        } else if (SimpleMetaType.INTEGER.equals(st)) {
            return new SimpleValueSupport(st, Integer.valueOf(value));
        } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, Integer.parseInt(value));
        } else if (SimpleMetaType.LONG.equals(st)) {
            return new SimpleValueSupport(st, Long.valueOf(value));
        } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, Long.parseLong(value));
        } else if (SimpleMetaType.SHORT.equals(st)) {
            return new SimpleValueSupport(st, Short.valueOf(value));
        } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
            return new SimpleValueSupport(st, Short.parseShort(value));
        } else if (SimpleMetaType.STRING.equals(st)) {
            return new SimpleValueSupport(st, value);
        }
    }
    throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
}