Package com.fasterxml.jackson.jr.ob.impl

Examples of com.fasterxml.jackson.jr.ob.impl.BeanDefinition


    }
   
    protected Object _readBean(Class<?> type, int typeId) throws IOException
    {
        if (typeId < 0) { // actual bean types
            BeanDefinition def = _typeDetector.getBeanDefinition(typeId);
            JsonToken t = _parser.getCurrentToken();

            try {
                Object bean = null;
                switch (t) {
                case VALUE_STRING:
                    bean = def.create(_parser.getText());
                    break;
                case VALUE_NUMBER_INT:
                    bean = def.create(_parser.getLongValue());
                    break;
                case START_OBJECT:
                    {
                        bean = def.create();
                        for (; (t = _parser.nextToken()) == JsonToken.FIELD_NAME; ) {
                            String fieldName = _parser.getCurrentName();
                            BeanProperty prop = def.findProperty(fieldName);
                            if (prop == null) {
                                if (JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY.isEnabled(_features)) {
                                    throw JSONObjectException.from(_parser, "Unrecognized JSON property '"
                                            +fieldName+"' for Bean type "+type.getName());
                                }
View Full Code Here


            writeUnknownField(fieldName, value);
            return;
        }

        if (type < 0) { // Bean type!
            BeanDefinition def = _typeDetector.getBeanDefinition(type);
            if (def == null) { // sanity check
                throw new IllegalStateException("Internal error: missing BeanDefinition for id "+type
                        +" (class "+value.getClass().getName()+")");
            }
            _generator.writeFieldName(fieldName);
View Full Code Here

            writeUnknownValue(value);
            return;
        }
       
        if (type < 0) { // Bean type!
            BeanDefinition def = _typeDetector.getBeanDefinition(type);
            if (def == null) { // sanity check
                throw new IllegalStateException("Internal error: missing BeanDefinition for id "+type
                        +" (class "+value.getClass().getName()+")");
            }
            writeBeanValue(def, value);
View Full Code Here

     */

    public void testSimpleWithSerialization()
    {
        TypeDetector td = TypeDetector.forWriter(JSON.Feature.defaults());
        BeanDefinition def = td.resolveBean(TestBean.class);
        assertNotNull(def);

        List<BeanProperty> props = Arrays.asList(def._properties);
        if (props.size() != 2) {
            fail("Expected 2 properties, found "+props.size()+": "+props);
View Full Code Here

    }

    public void testGenericTypeWithDeser()
    {
        TypeDetector td = TypeDetector.forReader(JSON.Feature.defaults());
        BeanDefinition def = td.resolveBean(LongBean.class);
        assertNotNull(def);

        Map<String,BeanProperty> props = def._propsByName;
        assertNotNull(props);
       
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.jr.ob.impl.BeanDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.