Changeset 400 for tapas/common


Ignore:
Timestamp:
03/08/12 15:19:16 (12 years ago)
Author:
vmipsl
Message:

objet Tapas entier avec sérialization

Location:
tapas/common
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • tapas/common/implementation/com/ether/JSONHelperImpl.java

    r399 r400  
    1313import org.springframework.beans.factory.InitializingBean; 
    1414 
    15 import java.util.AbstractCollection; 
    16 import java.util.ArrayList; 
    1715import java.util.Collection; 
    1816import java.util.Collections; 
    19 import java.util.List; 
    2017import java.util.Map; 
    2118 
     
    7875    public <T> T fromJSON( @NotNull final JSON json, @NotNull final Class<T> beanClass ) 
    7976    { 
    80         if( json.isArray() ) 
    81         { 
    82             final JSONArray jsonArray = JSONArray.fromObject( json, _jsonConfig ); 
    83             final Class<? super T> superclass = beanClass.getSuperclass(); 
    84             if( superclass.isAssignableFrom( AbstractCollection.class ) ) 
    85             { 
    86                 final Tapas tapas = new Tapas(); 
    87                 final List<Request> requests = new ArrayList<Request>(); 
    88                 for( final Object jsonElement : jsonArray ) 
    89                 { 
    90                     final Request request = fromJSON( (JSON) jsonElement, Request.class ); 
    91                     requests.add( request ); 
    92                 } 
    93                 tapas.setRequests( requests ); 
    94                 return (T) tapas; 
    95             } 
    96 // 
    97 //            if( beanClass.isArray() ) 
    98 //            { 
    99 //                final Class<?> componentType = beanClass.getComponentType(); 
    100 //                //json.sf.net does not support Long[] or long[] 
    101 //                if( Long.class.equals( componentType ) || Long.TYPE.equals( componentType ) ) 
    102 //                { 
    103 //                    final Integer[] integers = (Integer[]) JSONArray.toArray( jsonArray, Integer.class ); 
    104 //                    if( Long.class.equals( componentType ) ) 
    105 //                    { 
    106 //                        final Long[] resultArray = new Long[integers.length]; 
    107 //                        for( int i = 0; i < integers.length; ++i ) 
    108 //                            resultArray[i] = integers[i].longValue(); 
    109 //                        return (T) resultArray; 
    110 //                    } 
    111 //                    if( Long.TYPE.equals( componentType ) ) 
    112 //                    { 
    113 //                        final long[] resultArray = new long[integers.length]; 
    114 //                        for( int i = 0; i < integers.length; ++i ) 
    115 //                            resultArray[i] = integers[i].longValue(); 
    116 //                        return (T) resultArray; 
    117 //                    } 
    118 //                } 
    119 //                return (T) JSONArray.toArray( jsonArray, componentType ); 
    120 //            } 
    121 //            if( beanClass.isAssignableFrom( Collection.class ) ) 
    122 //            { 
    123 //                final TypeVariable<Class<T>>[] typeParameters = beanClass.getTypeParameters(); 
    124 //                if( null == typeParameters || typeParameters.length != 1 || null == typeParameters[0] ) 
    125 //                    return (T) JSONArray.toCollection( jsonArray ); 
    126 //                return (T) JSONArray.toCollection( jsonArray, typeParameters[0].getGenericDeclaration() ); 
    127 //            } 
    128         } 
    12977        final JSONObject jsonObject = JSONObject.fromObject( json, _jsonConfig ); 
    130         return (T) JSONObject.toBean( jsonObject, beanClass ); 
    131 //        return (T) JSONObject.toBean( jsonObject, beanClass, _mapClassesForDeserialization.get( beanClass ) ); 
     78        return (T) JSONObject.toBean( jsonObject, beanClass, _mapClassesForDeserialization.get( beanClass ) ); 
    13279    } 
    13380 
  • tapas/common/implementation/log4j.xml

    r376 r400  
    1010 
    1111    <appender name="file" class="org.apache.log4j.FileAppender"> 
    12         <param name="file" value="/home_local/workspace/tapas/web/log4j.log"/> 
     12        <param name="file" value="/home_local/workspaces/log4j_tapas.log"/> 
    1313        <layout class="org.apache.log4j.PatternLayout"> 
    1414            <param name="ConversionPattern" value="LOG4J %p %d{ISO8601} - %c{1} - %m%n"/> 
Note: See TracChangeset for help on using the changeset viewer.