public boolean canGet(String name) { AccessMethod accessmethod = getAccessMethod(name); return accessmethod == null ? false : accessmethod.canGet(); }
/** * Given an object to be serialised/deserialised, return a MethodAnalyser * object containing a hash of Method and Field accessors. The * <code>context</code> stores a hash of these analysers so they are only * ever computed once per context per object class analysed. * * @param objclass Either an object instance to be investigated, or an object class. * If a class is specified and no analyser is registered, a new * object will be created using newInstance() to be queried. * @param context the context * @return a MethodAnalyser */ public static MethodAnalyser constructMethodAnalyser(Class objclass, SAXalizerMappingContext context) { SAXalizerMapperEntry entry = context.mapper.byClass(objclass); try { MethodAnalyser togo = new MethodAnalyser(objclass, entry, context); return togo; } catch (Exception e) { throw UniversalRuntimeException.accumulate(e, "Error constructing method analyser for " + objclass); } }
private void absorbSAMSArray(SAXAccessMethodSpec[] setmethods, SAMSList tagMethods, SAMSList attrMethods) { condenseMethods(tagMethods, new ArrayEnumeration(setmethods), SAXAccessMethodSpec.XML_TAG); condenseMethods(attrMethods, new ArrayEnumeration(setmethods), SAXAccessMethodSpec.XML_ATTRIBUTE); if (setmethods != null) { for (int i = 0; i < setmethods.length; ++i) { checkBodyMethodSpec(setmethods[i]); } } }
if (denval instanceof CompletableDenumeration) { Object completed = ((CompletableDenumeration)denval).complete(); AccessMethod deliver = beingparsed.ma.getAccessMethod(denkey); deliver.setChildObject(beingparsed.object, completed); + " did not supply a map key"); PropertyAccessor pa = MethodAnalyser.getPropertyAccessor( beingparsed.objectpeer, mappingcontext); pa.setProperty(beingparsed.objectpeer, beingparsed.mapkey,
absorbSAMSList(entry, tagMethods, attrMethods); SAXAccessMethodSpec[] setMethods = so.getSAXSetMethods(); SAXAccessMethodSpec.convertToSetSpec(setMethods); absorbSAMSArray(setMethods, tagMethods, attrMethods); absorbSAMSArray(setAttrMethods, tagMethods, attrMethods); absorbSAMSArray(getMethods, tagMethods, attrMethods); + " getattr methods for " + o, Logger.DEBUG_INFORMATIONAL); absorbSAMSArray(getAttrMethods, tagMethods, attrMethods); || defaultinferrible) { entry = context.inferrer.inferEntry(objclass, entry); absorbSAMSList(entry, tagMethods, attrMethods); assembleGetters();
public boolean canSet(String name) { AccessMethod accessmethod = getAccessMethod(name); return accessmethod == null ? false : accessmethod.canSet(); }
private void absorbSAMSList(SAXalizerMapperEntry entry, SAMSList tagMethods, SAMSList attrMethods) { condenseMethods(tagMethods, Collections.enumeration(entry.getSAMSList()), SAXAccessMethodSpec.XML_TAG); condenseMethods(attrMethods, Collections.enumeration(entry.getSAMSList()), SAXAccessMethodSpec.XML_ATTRIBUTE); for (int i = 0; i < entry.size(); ++i) { checkBodyMethodSpec(entry.specAt(i)); } }
private String computeLocalID(Object bean, Object idstrategy, int index) { String localid = null; if (idstrategy instanceof DirectIndexStrategy) { localid = Integer.toString(index); } else { IDRemapStrategy remapstrategy = (IDRemapStrategy) idstrategy; MethodAnalyser ma = darapplier.getMappingContext().getAnalyser( bean.getClass()); AccessMethod sam = ma.getAccessMethod(remapstrategy.idfield); localid = sam.getChildObject(bean).toString(); } return localid; }
public Object getProperty(Object parent, String name) { AccessMethod accessmethod = getAccessMethod(name); if (accessmethod == null) { throw UniversalRuntimeException .accumulate(new PropertyException(), "Property " + name + " of object " + parent.getClass() + " not found"); } return accessmethod.getChildObject(parent); }
public void unlink(Object parent, String name) { AccessMethod accessmethod = getAccessMethod(name); if (accessmethod == null) { throw UniversalRuntimeException .accumulate(new PropertyException(), "Property " + name + " of object " + parent.getClass() + " not found"); } accessmethod.setChildObject(parent, null); }
public String resolveBean(Object bean) { // A line of code only Andy could love. return mappingcontext.generalLeafParser.render(mappingcontext.getAnalyser(bean.getClass()).getAccessMethod(path).getChildObject(bean)); } };
public boolean isMultiple(Object parent, String name) { AccessMethod accessmethod = getAccessMethod(name); if (accessmethod == null) { throw UniversalRuntimeException.accumulate(new PropertyException(), "Property " + name + " of " + targetclass + " not found"); } return accessmethod.isDenumerable(); }
public Class getPropertyType(Object parent, String name) { AccessMethod accessmethod = getAccessMethod(name); if (accessmethod == null) { throw UniversalRuntimeException.accumulate(new PropertyException(), "Property " + name + " of " + targetclass + " not found "); } return accessmethod.getAccessedType(); }
public void setProperty(Object parent, String name, Object value) { AccessMethod accessmethod = getAccessMethod(name); if (accessmethod == null) { throw UniversalRuntimeException .accumulate(new PropertyException(), "Property " + name + " of object " + parent.getClass() + " not found"); } else if (!accessmethod.canSet()) { throw UniversalRuntimeException.accumulate(new PropertyException(), "Property " + name + " of object " + parent.getClass() + " is not writeable"); } accessmethod.setChildObject(parent, value); }
public static AccessMethod findSingleGetter(Class objclass, SAXalizerMappingContext context, String tagname) { MethodAnalyser ma = context.getAnalyser(objclass); AccessMethod method = ma.getAccessMethod(tagname); if (!method.canGet() || method.isDenumerable()) { throw new UniversalRuntimeException( "Located access method of unsuitable type for name " + tagname + " in " + objclass); } return method; }
Object value = listprops.get(propname); MethodAnalyser ma = mappingContext.getAnalyser(bean.getClass()); AccessMethod sam = ma.getAccessMethod(propname); if (sam == null || !sam.canSet()) { throw new IllegalArgumentException("TLAB target bean " + beanName
AccessMethod parsespecaccess = ma.getAccessMethod("parseSpec"); String spec = ""; if (parsespecaccess.getDeclaringClass() == SimpleViewParameters.class) {
public DataAlterationRequest reshapeDAR(DataAlterationRequest toshape) { if (toshape.type.equals(DataAlterationRequest.ADD)) { String cutback = PathUtil.getToTailPath(toshape.path); // cutback may be null! so examine methods of cutback2. This MUST // be a concrete object!! String cutback2 = PathUtil.getToTailPath(cutback); String membername = PathUtil.getTailPath(cutback); Object lastentity = bma.getBeanValue(cutback2, rbl, addressibleBeanModel); MethodAnalyser ma = mappingcontext.getAnalyser(lastentity.getClass()); AccessMethod sam = ma.getAccessMethod(membername); String entityname = eni.getEntityName(sam.getDeclaredType()); if (entityname == null) { String message = "ID Defunnelling reshaper could not infer entity name for entity of type " + sam.getDeclaredType() + " - make sure to supply an EntityNameInferrer for this type"; Logger.log.warn(message); throw new IllegalArgumentException(message); } Object newentity = null; if (toshape.data != null) { // data has already been conformed in type to "oldvalue" and so is at least scalar String newentitypath = PathUtil.buildPath(entityname, (String)toshape.data); newentity = bma.getBeanValue(newentitypath, rbl, addressibleBeanModel); } DataAlterationRequest togo = new DataAlterationRequest(cutback, newentity); return togo; } else { return toshape; } }
public Object cloneWithRespect(Object bean, Class respectful) { Class beanclz = bean.getClass(); MethodAnalyser targetma = mappingcontext.getAnalyser(beanclz); MethodAnalyser respectma = mappingcontext.getAnalyser(respectful); Object togo = reflectivecache.construct(beanclz); for (int i = 0; i < targetma.allgetters.length; ++i) { AccessMethod pot = targetma.allgetters[i]; if (!pot.canGet() || !pot.canSet()) continue; String propname = pot.getPropertyName(); if (respectma.getAccessMethod(propname) != null) { Object getit = pot.getChildObject(bean); pot.setChildObject(togo, getit); } } return togo; } }
.getAccessMethod(d.tail); Class declared = sam.getDeclaredType(); Class container = declared == Object.class && lastobj != null ? lastobj.getClass()