/** * Get the type name. * @return the type name. */ public String getTypeName() { String ret = typename!=null? typename: type!=null? SReflect.getClassName(type): null; return ret; }
public String convertObject(Object val, Object context) { // String ret = ""+((Class)val).getCanonicalName(); // Todo: SReflect doesn not work for some case!? (Lars) String ret = SReflect.getClassName((Class)val); return ret; } };
public String convertObject(Object val, Object context) { String ret = SReflect.getClassName(val.getClass()); return ret; } };
public String convertObject(Object val, Object context) { Enum en = (Enum)val; String clazz = SReflect.getClassName(val.getClass()); String name = en.name(); return clazz+"="+name; } };
/** * Create a new ConstructorInfo. */ public ConstructorInfo(Constructor<?> m) { this.classname = m.getDeclaringClass().getName(); Class<?>[] ptypes = m.getParameterTypes(); this.parametertypes = new String[ptypes.length]; for(int i=0; i<parametertypes.length; i++) { parametertypes[i] = SReflect.getClassName(ptypes[i]); } }
/** * Gets the filename for a class. * @param cma * @param model * @return filename */ protected String getFileName(Class< ? > cma, String model) { String src = SUtil.convertURLToString(cma.getProtectionDomain().getCodeSource().getLocation()); return src+File.separator+SReflect.getClassName(cma)+".class"; }
/** * Get unqualified class name. * Also beautifies names of arrays (eg 'String[]' instead of '[LString;'). * @return The unqualified (without package) name of a class. */ public static String getUnqualifiedClassName(Class clazz) { String classname = getClassName(clazz); return getUnqualifiedTypeName(classname); }
/** * Create a new service info. */ public RequiredServiceInfo(String name, Class<?> type, boolean multiple, Class<?> multiplextype, RequiredServiceBinding binding, List<NFRPropertyInfo> nfprops) { this(name, type!=null ? new ClassInfo(SReflect.getClassName(type)) : null, multiple, multiplextype!=null ? new ClassInfo(SReflect.getClassName(multiplextype)) : null, binding, nfprops); }
/** * Create a new service info. */ public ProvidedServiceInfo(String name, Class<?> type, ProvidedServiceImplementation implementation, String scope, PublishInfo publish, List<UnparsedExpression> properties) { this(name, new ClassInfo(SReflect.getClassName(type)), implementation, scope, publish, properties); }
/** * Create a new service info. */ public RequiredServiceInfo(String name, Class<?> type, boolean multiple, Class<?> multiplextype, RequiredServiceBinding binding, List<NFRPropertyInfo> nfprops, Collection<String> tags) { this(name, type!=null ? new ClassInfo(SReflect.getClassName(type)) : null, multiple, multiplextype!=null ? new ClassInfo(SReflect.getClassName(multiplextype)) : null, binding, nfprops, tags); }
/** * Get the parametertypes as classes. * @return the parametertypes. */ public void setParameterTypes(Class<?>[] parametertypes) { this.parametertypes = new ClassInfo[parametertypes.length]; for(int i = 0; i < parametertypes.length; ++i) { // this.parametertypes[i] = new ClassInfo(parametertypes[i].getName()); this.parametertypes[i] = new ClassInfo(SReflect.getClassName(parametertypes[i])); } }
/** * Write a string to the buffer. */ public JsonWriteContext writeNameValue(String name, Class<?> val) { buffer.append(encodeJsonString(name)); buffer.append(":"); buffer.append("\"").append(SReflect.getClassName(val)).append("\""); return this; }
/** * */ public Object getReturnObject(Object object, Class clazz, boolean clone, ClassLoader targetcl) { Object ret = object; if(clone || targetcl!=null && !clazz.equals(SReflect.classForName0(SReflect.getClassName(clazz), targetcl))) { if(targetcl!=null) clazz = SReflect.classForName0(SReflect.getClassName(clazz), targetcl); int length = Array.getLength(object); Class type = clazz.getComponentType(); return Array.newInstance(type, length); } return ret; } }
/** * Create a new method info. */ public MethodInfo(String name, Class<?>[] parametertypes) { this.name = name; if(parametertypes!=null) { this.parametertypes = new ClassInfo[parametertypes.length]; for(int i = 0; i < parametertypes.length; ++i) { this.parametertypes[i] = new ClassInfo(SReflect.getClassName(parametertypes[i])); } } }
/** * Create a Java type. * @param clazz The java class. * @param kind The kind of type as defined in OAVJavaType. * @return The new type. */ public OAVJavaType createJavaType(Class clazz, String kind) { OAVJavaType type = new OAVJavaType(clazz, kind, this); if(contains(type)) throw new RuntimeException("Type already exists: "+clazz); types.put(SReflect.getClassName(clazz), type); return type; }
/** * Create a Java type. * @param clazz The java class. * @param kind The kind of type as defined in OAVJavaType. * @return The new type. */ public OAVJavaType createJavaType(Class clazz, String kind) { OAVJavaType type = new OAVJavaType(clazz, kind, this); if(contains(type)) throw new RuntimeException("Type already exists: "+clazz); types.put(SReflect.getClassName(clazz), type); return type; }
/** * */ public Object getReturnObject(Object object, Class<?> clazz, boolean clone, ClassLoader targetcl) { if(clazz!=null && targetcl!=null) clazz = SReflect.classForName0(SReflect.getClassName(clazz), targetcl); if(clazz==null) clazz = Object.class; int length = ((JsonArray)object).size(); return Array.newInstance(clazz, length); } }
/** * Create a new service info. */ public ProvidedServiceInfo(String name, Class<?> type, ProvidedServiceImplementation implementation, PublishInfo publish) { this.name = name; this.implementation = implementation; this.publish = publish; setType(new ClassInfo(SReflect.getClassName(type))); }
/** * Get the type. * @return The type. */ public Class<?> getType(ClassLoader cl) { if(cl==null) { throw new IllegalArgumentException("Not allowed with cl==null, use getType0() instead!"); } if(classloader!=cl) { type = SReflect.classForName0(type!=null? SReflect.getClassName(type): typename, cl); // Todo: assert that classloader is always the same -> currently reload required for bdi class rewriting? assert type!=null || classloader==null : "Try to load type :"+getTypeName()+" with wrong classloader: "+classloader+", "+cl; if(type!=null) { classloader = cl; } } return type; }
/** * Write the classname. * @param object */ public void writeClass(Class<?> clazz) { write("\"").write(JsonTraverser.CLASSNAME_MARKER).write("\""); write(":"); write("\"").write(SReflect.getClassName(clazz)).write("\""); }