/** * PUBLIC: * Add the field and the name of the method * that returns the value to be placed in said field * when the object is written to the database. * The method may take zero arguments, or it may * take a single argument of type * <code>org.eclipse.persistence.sessions.Session</code>. */ public void addFieldTransformation(DatabaseField field, String methodName) { MethodBasedFieldTransformation transformation = new MethodBasedFieldTransformation(); transformation.setField(field); transformation.setMethodName(methodName); getFieldTransformations().add(transformation); }
public FieldTransformer buildTransformer() throws Exception { return new MethodBasedFieldTransformer(getMethodName()); } }
MethodBasedFieldTransformation methodTransformation = (MethodBasedFieldTransformation) transformation; try { Class returnType = Helper.getDeclaredMethod(mapping.getDescriptor().getJavaClass(), methodTransformation.getMethodName(), null).getReturnType(); getFieldDefFromDBField(methodTransformation.getField()).setType(returnType); } catch (NoSuchMethodException ex) {
MethodBasedFieldTransformation methodTransformation = (MethodBasedFieldTransformation) transformation; try { Class returnType = Helper.getDeclaredMethod(mapping.getDescriptor().getJavaClass(), methodTransformation.getMethodName(), null).getReturnType(); getFieldDefFromDBField(methodTransformation.getField()).setType(returnType); } catch (NoSuchMethodException ex) {
/** * PUBLIC: * Add the field and the name of the method * that returns the value to be placed in said field * when the object is written to the database. * The method may take zero arguments, or it may * take a single argument of type * <code>org.eclipse.persistence.sessions.Session</code>. */ public void addFieldTransformation(DatabaseField field, String methodName) { MethodBasedFieldTransformation transformation = new MethodBasedFieldTransformation(); transformation.setField(field); transformation.setMethodName(methodName); getFieldTransformations().add(transformation); }
public FieldTransformer buildTransformer() throws Exception { return new MethodBasedFieldTransformer(getMethodName()); } }
MethodBasedFieldTransformation methodTransformation = (MethodBasedFieldTransformation) transformation; try { Class returnType = Helper.getDeclaredMethod(mapping.getDescriptor().getJavaClass(), methodTransformation.getMethodName(), null).getReturnType(); getFieldDefFromDBField(methodTransformation.getField(), false).setType(returnType); } catch (NoSuchMethodException ex) {
/** * PUBLIC: * Add the field and the name of the method * that returns the value to be placed in said field * when the object is written to the database. * The method may take zero arguments, or it may * take a single argument of type * <code>org.eclipse.persistence.sessions.Session</code>. */ public void addFieldTransformation(DatabaseField field, String methodName) { MethodBasedFieldTransformation transformation = new MethodBasedFieldTransformation(); transformation.setField(field); transformation.setMethodName(methodName); getFieldTransformations().addElement(transformation); }
public FieldTransformer buildTransformer() throws Exception { return new MethodBasedFieldTransformer(getMethodName()); } }
/** * INTERNAL: * needed for backwards compatibility */ public void setFieldNameToMethodNameAssociations(Vector associations) { setFieldTransformations(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(associations.size())); for (Iterator source = associations.iterator(); source.hasNext();) { Association ass = (Association)source.next(); MethodBasedFieldTransformation tf = new MethodBasedFieldTransformation(); tf.setField(new DatabaseField((String)ass.getKey())); tf.setMethodName((String)ass.getValue()); getFieldTransformations().add(tf); } }
/** * INTERNAL: * Required for reverse compatibility and test cases: * @return a hash table containing the fieldName and their respective method names */ public Hashtable getFieldNameToMethodNames() { Hashtable table = new Hashtable(getFieldTransformations().size()); Iterator transformations = getFieldTransformations().iterator(); while (transformations.hasNext()) { FieldTransformation transformation = (FieldTransformation)transformations.next(); if (transformation instanceof MethodBasedFieldTransformation) { table.put(transformation.getField().getQualifiedName(), ((MethodBasedFieldTransformation)transformation).getMethodName()); } } return table; }
/** * INTERNAL: * needed for backwards compatibility */ public void setFieldNameToMethodNameAssociations(Vector associations) { setFieldTransformations(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(associations.size())); for (Iterator source = associations.iterator(); source.hasNext();) { Association ass = (Association)source.next(); MethodBasedFieldTransformation tf = new MethodBasedFieldTransformation(); tf.setField(new DatabaseField((String)ass.getKey())); tf.setMethodName((String)ass.getValue()); getFieldTransformations().addElement(tf); } }
/** * INTERNAL: * Required for reverse compatibility and test cases: * @return a hash table containing the fieldName and their respective method names */ public Hashtable getFieldNameToMethodNames() { Hashtable table = new Hashtable(getFieldTransformations().size()); Iterator transformations = getFieldTransformations().iterator(); while (transformations.hasNext()) { FieldTransformation transformation = (FieldTransformation)transformations.next(); if (transformation instanceof MethodBasedFieldTransformation) { table.put(transformation.getField().getQualifiedName(), ((MethodBasedFieldTransformation)transformation).getMethodName()); } } return table; }
/** * INTERNAL: * needed for backwards compatibility */ public void setFieldNameToMethodNameAssociations(Vector associations) { setFieldTransformations(org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(associations.size())); for (Iterator source = associations.iterator(); source.hasNext();) { Association ass = (Association)source.next(); MethodBasedFieldTransformation tf = new MethodBasedFieldTransformation(); tf.setField(new DatabaseField((String)ass.getKey())); tf.setMethodName((String)ass.getValue()); getFieldTransformations().add(tf); } }
/** * INTERNAL: * Required for reverse compatibility and test cases: * @return a hash table containing the fieldName and their respective method names */ public Hashtable getFieldNameToMethodNames() { Hashtable table = new Hashtable(getFieldTransformations().size()); Iterator transformations = getFieldTransformations().iterator(); while (transformations.hasNext()) { FieldTransformation transformation = (FieldTransformation)transformations.next(); if (transformation instanceof MethodBasedFieldTransformation) { table.put(transformation.getField().getQualifiedName(), ((MethodBasedFieldTransformation)transformation).getMethodName()); } } return table; }
/** * INTERNAL: * Needed for backwards compatibility */ public Vector getFieldNameToMethodNameAssociations() { Vector associations = new Vector(); for (Iterator source = getFieldTransformations().iterator(); source.hasNext();) { FieldTransformation tf = (FieldTransformation)source.next(); if (tf instanceof MethodBasedFieldTransformation) { Association ass = new Association(); ass.setKey(tf.getField().getQualifiedName()); ass.setValue(((MethodBasedFieldTransformation)tf).getMethodName()); associations.addElement(ass); } } return associations; }
/** * INTERNAL: * Needed for backwards compatibility */ public Vector getFieldNameToMethodNameAssociations() { Vector associations = new Vector(); for (Iterator source = getFieldTransformations().iterator(); source.hasNext();) { FieldTransformation tf = (FieldTransformation)source.next(); if (tf instanceof MethodBasedFieldTransformation) { Association ass = new Association(); ass.setKey(tf.getField().getQualifiedName()); ass.setValue(((MethodBasedFieldTransformation)tf).getMethodName()); associations.addElement(ass); } } return associations; }
/** * INTERNAL: * Needed for backwards compatibility */ public Vector getFieldNameToMethodNameAssociations() { Vector associations = new Vector(); for (Iterator source = getFieldTransformations().iterator(); source.hasNext();) { FieldTransformation tf = (FieldTransformation)source.next(); if (tf instanceof MethodBasedFieldTransformation) { Association ass = new Association(); ass.setKey(tf.getField().getQualifiedName()); ass.setValue(((MethodBasedFieldTransformation)tf).getMethodName()); associations.addElement(ass); } } return associations; }
protected void addTransformationMappingLines(NonreflectiveMethodDefinition method, String mappingName, TransformationMapping mapping) { if (!mapping.isWriteOnly()) { if (mapping.getAttributeMethodName() != null) { method.addLine(mappingName + ".setAttributeTransformation(\"" + mapping.getAttributeMethodName() + "\");"); } else { method.addLine(mappingName + ".setAttributeTransformer(new " + mapping.getAttributeTransformerClassName() + "());"); } } Iterator fieldTransformations = mapping.getFieldTransformations().iterator(); while (fieldTransformations.hasNext()) { FieldTransformation trans = (FieldTransformation)fieldTransformations.next(); String fieldName = trans.getFieldName(); if (trans instanceof MethodBasedFieldTransformation) { String methodName = ((MethodBasedFieldTransformation)trans).getMethodName(); method.addLine(mappingName + ".addFieldTransformation(\"" + fieldName + "\", \"" + methodName + "\");"); } else { String transformerClass = ((TransformerBasedFieldTransformation)trans).getTransformerClassName(); method.addLine(mappingName + ".addFieldTransformer(\"" + fieldName + "\", new " + transformerClass + "());"); } } IndirectionPolicy policy = mapping.getIndirectionPolicy(); if (policy instanceof ContainerIndirectionPolicy) { String containerClassName = ((ContainerIndirectionPolicy)policy).getContainerClassName(); method.addLine(mappingName + ".useContainerIndirection(" + containerClassName + ".class);"); } else if (policy instanceof BasicIndirectionPolicy) { method.addLine(mappingName + ".useBasicIndirection();"); } method.addLine(mappingName + ".setIsMutable(" + mapping.isMutable() + ");"); }
protected void addTransformationMappingLines(NonreflectiveMethodDefinition method, String mappingName, TransformationMapping mapping) { if (!mapping.isWriteOnly()) { if (mapping.getAttributeMethodName() != null) { method.addLine(mappingName + ".setAttributeTransformation(\"" + mapping.getAttributeMethodName() + "\");"); } else { method.addLine(mappingName + ".setAttributeTransformer(new " + mapping.getAttributeTransformerClassName() + "());"); } } Iterator fieldTransformations = mapping.getFieldTransformations().iterator(); while (fieldTransformations.hasNext()) { FieldTransformation trans = (FieldTransformation)fieldTransformations.next(); String fieldName = trans.getFieldName(); if (trans instanceof MethodBasedFieldTransformation) { String methodName = ((MethodBasedFieldTransformation)trans).getMethodName(); method.addLine(mappingName + ".addFieldTransformation(\"" + fieldName + "\", \"" + methodName + "\");"); } else { String transformerClass = ((TransformerBasedFieldTransformation)trans).getTransformerClassName(); method.addLine(mappingName + ".addFieldTransformer(\"" + fieldName + "\", new " + transformerClass + "());"); } } IndirectionPolicy policy = mapping.getIndirectionPolicy(); if (policy instanceof ContainerIndirectionPolicy) { String containerClassName = ((ContainerIndirectionPolicy)policy).getContainerClassName(); method.addLine(mappingName + ".useContainerIndirection(" + containerClassName + ".class);"); } else if (policy instanceof BasicIndirectionPolicy) { method.addLine(mappingName + ".useBasicIndirection();"); } method.addLine(mappingName + ".setIsMutable(" + mapping.isMutable() + ");"); }