예제 #1
0
 public ObjectWrapper getWrapper(Class clazz) {
   ObjectWrapper ret;
   String classname = clazz.getName();
   if (handlers != null && handlers.containsKey(classname)) ret = initWrapper(classname, clazz);
   else {
     if (Map.class.isAssignableFrom(clazz)) ret = new DefaultMapWrapper(clazz);
     else if (Collection.class.isAssignableFrom(clazz)) ret = new DefaultCollectionWrapper(clazz);
     else if (clazz.isArray()) ret = new ArrayWrapper(clazz);
     else if (ReflectionUtil.isSimpleType(clazz)) return new DefaultSimpleTypeWrapper(clazz);
     else if (clazz.isEnum()) ret = new EnumWrapper(clazz);
     else ret = new DefaultBeanWrapper(clazz);
   }
   ret.setYamlConfig(this);
   return ret;
 }
예제 #2
0
 public ObjectWrapper getWrapperSetContent(String classname, String content) {
   SimpleObjectWrapper wrapper;
   Class type = ReflectionUtil.classForName(transfer2classname(classname));
   if (handlers != null && handlers.containsKey(classname)) {
     wrapper = (SimpleObjectWrapper) initWrapper(classname, type);
     wrapper.setObject(Utilities.convertType(content, wrapper.expectedArgType()));
   } else if (type != null && type.isEnum()) {
     wrapper = new EnumWrapper(type);
     wrapper.setObject(Utilities.convertType(content, wrapper.expectedArgType()));
   } else {
     wrapper = new DefaultSimpleTypeWrapper(type);
     wrapper.setObject(Utilities.convertType(content, wrapper.expectedArgType()));
   }
   wrapper.setYamlConfig(this);
   return wrapper;
 }
예제 #3
0
 public boolean isConstructorAccessibleForDecoding(Class clazz) {
   try {
     Constructor constr = clazz.getDeclaredConstructor(null);
     return isWithin(constr.getModifiers(), decodingAccessScope.get(CONSTRUCTOR_SCOPE));
   } catch (Exception e) {
     return false;
   }
 }