/** * Get the parametertypes as classes. * @return the parametertypes. */ public Class<?>[] getParameterTypes(ClassLoader cl) { Class<?>[] typeclasses = new Class<?>[parametertypes.length]; for (int i = 0; i < parametertypes.length; ++i) { typeclasses[i] = parametertypes[i].getType(cl); } return typeclasses; }
public String convertObject(Object val, Object context) { return ((ClassInfo) val).getTypeName(); } }
/** * Create a new service identifier. */ public ServiceIdentifier(IComponentIdentifier providerid, Class<?> type, String servicename, IResourceIdentifier rid) { this.providerid = providerid; this.type = new ClassInfo(type); this.servicename = servicename; this.rid = rid; }
/** * */ public String convertToString(ClassInfo val) { // return val==null || val.getTypeName().length()==0? null: val.getPrefixNotation(); return val==null || val.getTypeName().length()==0? null: SReflect.getUnqualifiedTypeName(val.getGenericTypeName()); }
public Object postProcess(IContext context, Object object) { MParameter param = (MParameter) object; param.getInitialValue().setName(param.getName()); param.getInitialValue().getClazz().setTypeName(param.getClazz().getTypeName()); return object; } },
/** * Get the name with parameters, e.g. method1(String, int) * but without return type. */ public String getNameWithParameters() { StringBuffer buf = new StringBuffer(); buf.append(getName()); if(parametertypes!=null && parametertypes.length>0) { buf.append("("); for(int i=0; i<parametertypes.length; i++) { ClassInfo ci = parametertypes[i]; buf.append(SReflect.getUnqualifiedTypeName(ci.toString())); if(i+1<parametertypes.length) buf.append(", "); } buf.append(")"); } return buf.toString(); } }
/** * Get the string representation. */ public String toString() { return getGenericTypeName()!=null? getGenericTypeName(): "n/a"; }
/** * */ public ClassInfo getModelValue(String val) { ClassInfo ret = null; boolean suffix = val.indexOf(".")==-1; for(ClassInfo item : entries) { if(item.getTypeName().equals(val) || item.getGenericTypeName().equals(val) || (suffix && item.getTypeName().endsWith(val))) { ret = item; break; } } return ret; } }
public void finished() { ret.setExceptionIfUndone(new ServiceNotFoundException(type.toString())); }
ret = getGenericTypeName().equals(ci.getGenericTypeName());
/** * */ public MethodInfo getBodyMethod(ClassLoader cl) { if(clazz!=null) { if(bodymethod==null) { synchronized(this) { if(bodymethod==null) { Class<?> body = clazz.getType(cl); bodymethod = getMethod(body, PlanBody.class, cl); if(bodymethod==null) throw new RuntimeException("Plan has no body method: "+body); } } } } return bodymethod; }
/** * Get the generic type name. * @return The type name. */ public String getGenericTypeName() { return geninfo!=null? geninfo: getTypeName(); }
/** * Create a new service identifier. */ public ServiceIdentifier(IComponentIdentifier providerid, Class<?> type, String servicename, IResourceIdentifier rid, String scope) { this(providerid, new ClassInfo(type), servicename, rid, scope); }
/** * Process an object. * @param object The object. * @param targetcl If not null, the traverser should make sure that the result object is compatible with the class loader, * e.g. by cloning the object using the class loaded from the target class loader. * @return The processed object. */ public Object process(Object object, Type type, List<ITraverseProcessor> processors, Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context) { JsonWriteContext wr = (JsonWriteContext)context; wr.addObject(traversed, object); wr.write("{"); wr.writeNameValue("value", "\""+((ClassInfo)object).getGenericTypeName()+"\""); if(wr.isWriteClass()) wr.write(",").writeClass(object.getClass()); if(wr.isWriteId()) wr.write(",").writeId(); wr.write("}"); return object; } }
public void customResultAvailable(ClassLoader cl) { ret.setResult(sid.getServiceType().getType(cl)); } });
/** * Get the hashcode. */ public int hashCode() { final int prime = 31; int result = 1; // result = prime * result + ((getGenericTypeName() == null)? 0 : getGenericTypeName().hashCode()); result = prime * result + ((getTypeName() == null)? 0 : getTypeName().hashCode()); return result; }
public Object convertString(String val, Object context) throws Exception { return new ClassInfo(val); }
public void actionPerformed(ActionEvent e) { ClassInfo ci = (ClassInfo)cbranking.getSelectedItem(); if(ci!=null) { // System.out.println("setting: "+method); MProperty mprop = task.getProperties().get(PROPERTY_RANKING); UnparsedExpression uexp = new UnparsedExpression(null, String.class, "\""+ci.toString()+"\"", null); mprop.setInitialValue(uexp); } } });