String fieldName = entry.getKey(); TypeUtil.FieldInfo fieldInfo = entry.getValue(); if (!Collection.class.isAssignableFrom(fieldInfo.getType())) { validFieldNames.add(fieldName);
try { type = TypeUtil.getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType().getName(); } catch (Exception e3) {
&& (!"getFieldType".equals(getter.getName())) && (!"getElementType".equals(getter.getName()))) { FieldInfo info = new FieldInfo(fieldName, getter, setter, proxySetter, proxyGetter, adder); infos.put(fieldName, info);
String fieldName = entry.getKey(); TypeUtil.FieldInfo fieldInfo = entry.getValue(); if (!Collection.class.isAssignableFrom(fieldInfo.getType())) { validFieldNames.add(fieldName);
if (a[i].startsWith("a")) { String fieldName = a[i].substring(1).intern(); Class<?> fieldClass = fieldInfos.get(fieldName).getType(); String firstString = (i + 1 == a.length ? "" : a[i + 1]); StringBuffer string = null; if (a[i].startsWith("a")) { String fieldName = a[i].substring(1); Class<?> fieldClass = fieldInfos.get(fieldName).getType(); String firstString = (i + 1 == a.length ? "" : a[i + 1]); StringBuffer string = null;
if (a[i].startsWith("a")) { String fieldName = a[i].substring(1).intern(); Class<?> fieldClass = fieldInfos.get(fieldName).getType(); String firstString = (i + 1 == a.length ? "" : a[i + 1]); StringBuffer string = null; if (a[i].startsWith("a")) { String fieldName = a[i].substring(1); Class<?> fieldClass = fieldInfos.get(fieldName).getType(); String firstString = (i + 1 == a.length ? "" : a[i + 1]); StringBuffer string = null;
for (FieldDescriptor field : fields) { String fieldName = field.getName(); Class<?> fieldType = fieldInfos.get(fieldName).getType(); if (InterMineObject.class.isAssignableFrom(fieldType)) { String fieldAlias = DatabaseUtil.getColumnName(field).toLowerCase();
throw new MetaDataException(message); Class<?> attrClass = info.getType(); if (!"id".equalsIgnoreCase(attr.getName())) { Object value = null;
for (FieldDescriptor field : fields) { String fieldName = field.getName(); Class<?> fieldType = fieldInfos.get(fieldName).getType(); if (InterMineObject.class.isAssignableFrom(fieldType)) { String fieldAlias = DatabaseUtil.getColumnName(field).toLowerCase();
throw new MetaDataException(message); Class<?> attrClass = info.getType(); if (!"id".equalsIgnoreCase(attr.getName())) { Object value = null;
: TypeUtil.getFieldInfos(o.getClass()).entrySet()) { TypeUtil.FieldInfo fieldInfo = fieldEntry.getValue(); if (InterMineObject.class.isAssignableFrom(fieldInfo.getType())) { InterMineObject obj = (InterMineObject) TypeUtil.getFieldProxy(o, fieldInfo.getName()); if ((obj != null) && (obj.getId() == null)) { obj.setId(getSerialWithConnection(c)); } else if (Collection.class.isAssignableFrom(fieldInfo.getType())) { @SuppressWarnings("unchecked") Collection<Object> coll = (Collection<Object>) o.getFieldValue(fieldInfo.getName());
&& (!"getFieldType".equals(getter.getName())) && (!"getElementType".equals(getter.getName()))) { FieldInfo info = new FieldInfo(fieldName, getter, setter, proxySetter, proxyGetter, adder); infos.put(fieldName, info);
: TypeUtil.getFieldInfos(o.getClass()).entrySet()) { TypeUtil.FieldInfo fieldInfo = fieldEntry.getValue(); if (InterMineObject.class.isAssignableFrom(fieldInfo.getType())) { InterMineObject obj = (InterMineObject) TypeUtil.getFieldProxy(o, fieldInfo.getName()); if ((obj != null) && (obj.getId() == null)) { obj.setId(getSerialWithConnection(c)); } else if (Collection.class.isAssignableFrom(fieldInfo.getType())) { @SuppressWarnings("unchecked") Collection<Object> coll = (Collection<Object>) o.getFieldValue(fieldInfo.getName());
try { type = TypeUtil.getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType().getName(); } catch (Exception e3) {
/** * Returns the value of a public or protected Field of an Object given by the field name without * dereferencing any ProxyReference objects. * * @param o the Object * @param fieldName the name of the relevant Field * @return the value of the field, without dereferencing ProxyReferences * @throws IllegalAccessException if the field is inaccessible */ public static Object getFieldProxy(Object o, String fieldName) throws IllegalAccessException { try { Method proxyGetter = getProxyGetter(o.getClass(), fieldName); if (proxyGetter == null) { proxyGetter = getGetter(o.getClass(), fieldName); } return proxyGetter.invoke(o, new Object[] {}); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType().getName(); } catch (Exception e3) { // ignore } IllegalAccessException e2 = new IllegalAccessException("Couldn't proxyGet field \"" + o.getClass().getName() + "." + fieldName + "\"" + (type == null ? "" : " (a " + type + ")")); e2.initCause(e); throw e2; } }
/** * Returns the value of a public or protected Field of an Object given by the field name without * dereferencing any ProxyReference objects. * * @param o the Object * @param fieldName the name of the relevant Field * @return the value of the field, without dereferencing ProxyReferences * @throws IllegalAccessException if the field is inaccessible */ public static Object getFieldProxy(Object o, String fieldName) throws IllegalAccessException { try { Method proxyGetter = getProxyGetter(o.getClass(), fieldName); if (proxyGetter == null) { proxyGetter = getGetter(o.getClass(), fieldName); } return proxyGetter.invoke(o, new Object[] {}); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType().getName(); } catch (Exception e3) { // ignore } IllegalAccessException e2 = new IllegalAccessException("Couldn't proxyGet field \"" + o.getClass().getName() + "." + fieldName + "\"" + (type == null ? "" : " (a " + type + ")")); e2.initCause(e); throw e2; } }
/** * Adds an element to a public or protected collection of an Object given the field name. * * @param o the Object * @param fieldName the name of the relevant collection * @param element the element to add to the collection */ public static void addCollectionElement(Object o, String fieldName, Object element) { try { getAdder(o.getClass(), fieldName).invoke(o, element); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getElementType().getName(); } catch (Exception e3) { IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " - not an accessible collection"); e2.initCause(e); throw e2; } IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " (a " + type + ") with \"" + element + "\" (a " + element.getClass().getName() + ")"); e2.initCause(e); throw e2; } }
/** * Adds an element to a public or protected collection of an Object given the field name. * * @param o the Object * @param fieldName the name of the relevant collection * @param element the element to add to the collection */ public static void addCollectionElement(Object o, String fieldName, Object element) { try { getAdder(o.getClass(), fieldName).invoke(o, element); } catch (Exception e) { String type = null; try { type = getFieldInfo(o.getClass(), fieldName).getElementType().getName(); } catch (Exception e3) { IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " - not an accessible collection"); e2.initCause(e); throw e2; } IllegalArgumentException e2 = new IllegalArgumentException("Couldn't add element to" + " collection \"" + Util.getFriendlyName(o.getClass()) + "." + fieldName + "\"" + " (a " + type + ") with \"" + element + "\" (a " + element.getClass().getName() + ")"); e2.initCause(e); throw e2; } }
/** * Writes the contents of any pending Clobs to the database, and replaces them in the objects * with a real ClobAccess object. * * @param c a connection * @param o the object to transform * @throws ObjectStoreException if something goes wrong * @throws SQLException if something goes wrong * @throws IllegalAccessException if something goes wrong */ protected void writePendingClobs(Connection c, Object o) throws ObjectStoreException, SQLException, IllegalAccessException { for (Map.Entry<String, TypeUtil.FieldInfo> fieldEntry : TypeUtil.getFieldInfos(o.getClass()).entrySet()) { TypeUtil.FieldInfo fieldInfo = fieldEntry.getValue(); if (ClobAccess.class.isAssignableFrom(fieldInfo.getType())) { ClobAccess ca = (ClobAccess) TypeUtil.getFieldValue(o, fieldInfo.getName()); if (ca instanceof PendingClob) { // We can't call createClob here - we already have a connection, and // we must use that one. Clob clob = new Clob(getSerialWithConnection(c)); replaceClobWithConnection(c, clob, ((PendingClob) ca) .toString()); DynamicUtil.setFieldValue(o, fieldInfo.getName(), new ClobAccess(this, clob)); } } } }
/** * Returns the value of a public or protected Field of an Object given the field name * * @param o the Object * @param fieldName the name of the relevant Field * @return the value of the Field * @throws IllegalAccessException if the field is inaccessible */ public static Object getFieldValue(Object o, String fieldName) throws IllegalAccessException { try { return getGetter(o.getClass(), fieldName).invoke(o, new Object[] {}); } catch (Exception e) { String type = ""; try { type = " (a " + getFieldInfo(o.getClass(), fieldName).getGetter().getReturnType() .getName() + ")"; } catch (Exception e3) { type = " (available fields are " + getFieldInfos(o.getClass()).keySet() + ")"; } IllegalAccessException e2 = new IllegalAccessException("Couldn't get field \"" + Util.decomposeClass(o.getClass()) + "." + fieldName + "\"" + type); e2.initCause(e); throw e2; } }