/** * reflect - reflect a JavaClass for a given qualified name. If the package or class does not exist, one will be created through the reflection * mechanism. Lookup the JavaClass in the context of the passed object, handling some error cases. * * @deprecated @see org.eclipse.jem.java.JavaRefFactory#reflectType(java.lang.String, org.eclipse.emf.ecore.EObject) * */ public static JavaHelpers reflect(String aQualifiedName, EObject relatedObject) { return JavaRefFactory.eINSTANCE.reflectType(aQualifiedName, relatedObject); }
protected EClassifier getGeneratedIdType() { if (fGeneratedIdType == null) { fGeneratedIdType = JavaRefFactory.eINSTANCE.reflectType(JAVA_LANG_STRING, this); } return fGeneratedIdType; } /**
/** * reflect - reflect a JavaClass for a given qualified name. If the package or class does not exist, one will be created through the reflection * mechanism. * * @deprecated @see org.eclipse.jem.java.JavaRefFactory#reflectType(java.lang.String, org.eclipse.emf.ecore.resource.ResourceSet) */ public static JavaHelpers reflect(String aQualifiedName, ResourceSet set) { return JavaRefFactory.eINSTANCE.reflectType(aQualifiedName, set); }
/** * reflect - reflect a JavaClass for a given package name or class name. If the package or class does not exist, one will be created through the * reflection mechanism. * * @deprecated @see org.eclipse.jem.java.JavaRefFactory#reflectType(java.lang.String, java.lang.String, * org.eclipse.emf.ecore.resource.ResourceSet) */ public static JavaHelpers reflect(String aPackageName, String aClassName, ResourceSet set) { return JavaRefFactory.eINSTANCE.reflectType(aPackageName, aClassName, set); }
public Collection getChoiceOfValues(Object o) { CMPAttribute thisCMPAttribute = (CMPAttribute) o; Collection result = new ArrayList(); for (int i = 0; i < choiceOfTypes.length; ++i) { result.add(JavaRefFactory.eINSTANCE.reflectType(choiceOfTypes[i], thisCMPAttribute)); } return result; } });
public JavaClass getWrapper() { String wrapperName = getWrapperQualifiedName(); if (wrapperName != null) { return (JavaClass) JavaRefFactory.eINSTANCE.reflectType(wrapperName, this); } return null; } /**
/** * Get the final component type for this Array Type. * * In order to ensure a unique instance, we will resolve this type using reflection. It turns out to be most efficient to just do this by trimming the name. */ public JavaHelpers getFinalComponentType() { if (finalComponentType == null) { String componentName = getQualifiedNameForReflection(); // Strip all the [] from my name to get my FINAL component type's name componentName = componentName.substring(0, componentName.indexOf("[")); finalComponentType = JavaRefFactory.eINSTANCE.reflectType(componentName, this); } return finalComponentType; } /**
/** * Compute the component type for this array type from our type name. * The component type of this array type is essentially: new ArrayTypeImpl(finalComponentType, arrayDimensions-1) * unless our array dimension is 1, in which case it is only our final component type. * * In order to ensure a unique instance, we will resolve this type using reflection. * "java.lang.String[][]" component type is "java.lang.String[]" * */ public JavaHelpers computeComponentType() { String componentName = getQualifiedNameForReflection(); // Strip the last [] form my name to get my component type's name componentName = componentName.substring(0, componentName.length() - 2); return JavaRefFactory.eINSTANCE.reflectType(componentName, this); } /**
private JavaClass getEJBHomeClass(EnterpriseBean bean) { Resource res = bean.eResource(); ResourceSet set = res != null ? res.getResourceSet() : null; return (JavaClass) JavaRefFactory.eINSTANCE.reflectType("javax.ejb", "EJBHome", set); //$NON-NLS-1$ //$NON-NLS-2$ } }
private JavaClass getEJBObjectClass(EnterpriseBean bean) { Resource res = bean.eResource(); ResourceSet set = res != null ? res.getResourceSet() : null; return (JavaClass) JavaRefFactory.eINSTANCE.reflectType("javax.ejb", "EJBObject", set); //$NON-NLS-1$ //$NON-NLS-2$ } private JavaClass getEJBLocalObjectClass(EnterpriseBean bean) {
private JavaClass getEJBLocalObjectClass(EnterpriseBean bean) { Resource res = bean.eResource(); ResourceSet set = res != null ? res.getResourceSet() : null; return (JavaClass) JavaRefFactory.eINSTANCE.reflectType("javax.ejb", "EJBLocalObject", set); //$NON-NLS-1$ //$NON-NLS-2$ } private JavaClass getEJBHomeClass(EnterpriseBean bean) {
protected void setDeclaringClass() { Class declaringType = getSourceType().getDeclaringClass(); if (declaringType != null) { // Need to get it and reflect it so that the declared type of this target is set correctly. We can just // set it ourselves directly because ECore would try to add it to the list of inner classes of the declaring type. This // would cause it to be added twice, once from the reflection caused by the inverse setting, and once from our doing // the inverse setting itself. ResourceSet set = getTargetResource().getResourceSet(); JavaClassImpl declaringClass = (JavaClassImpl) JavaRefFactory.eINSTANCE.reflectType(declaringType.getName(), set); declaringClass.getDeclaredClasses(); // This will cause it to put us into its list and also set our declaring class to this declaring type. } }
/** * */ protected void reflectInnerClasses() { Class[] innerClasses = getSourceType().getClasses(); if (innerClasses.length != 0) { List declaredClasses = getJavaClassTarget().getDeclaredClassesGen(); JavaClass inner; ResourceSet set = getTargetResource().getResourceSet(); for (int i = 0; i < innerClasses.length; i++) { inner = (JavaClass) JavaRefFactory.eINSTANCE.reflectType(innerClasses[i].getName(), set); declaredClasses.add(inner); } } }
/** * @see com.ibm.etools.emf2xml.impl.Translator#convertStringToValue(String) */ public Object convertStringToValue(String strValue, EObject owner) { if (strValue != null) { String qualifiedName = removePreceedingAndTrailingPeriods(strValue.trim()); if (owner != null) { Resource ownerRes = owner.eResource(); if (ownerRes != null) { ResourceSet rs = ownerRes.getResourceSet(); if (rs != null) { //Try to reflect the type directly. If nothing is returned //or an error occurs, return a proxy. Object javaClass = null; try { javaClass = JavaRefFactory.eINSTANCE.reflectType(qualifiedName, rs); } catch (Exception e) { //Ignore } if (javaClass != null) return javaClass; } } } return JavaRefFactory.eINSTANCE.createClassRef(qualifiedName); } return null; } private String removePreceedingAndTrailingPeriods(String qualifiedName) {
public boolean reflectValues() { ArrayTypeImpl at = (ArrayTypeImpl) getTarget(); // Arrays are always: // final // Supertype of java.lang.Object // implements java.lang.Cloneable, java.io.Serializable at.setFinal(true); try { at.setSupertype((JavaClass) JavaRefFactory.eINSTANCE.reflectType("java.lang.Object", (EObject) getTarget())); //$NON-NLS-1$ } catch (InheritanceCycleException e) { } List list = at.getImplementsInterfacesGen(); list.add(JavaRefFactory.eINSTANCE.createClassRef("java.lang.Cloneable")); //$NON-NLS-1$ list.add(JavaRefFactory.eINSTANCE.createClassRef("java.io.Serializable")); //$NON-NLS-1$ return super.reflectValues(); }
JavaHelpers helper = JavaRefFactory.eINSTANCE.reflectType(javaClassName, resourceSet); if(throwExcIfNotValid) {
public static EnterpriseBean getEnterpriseBean(ICompilationUnit cu) { IProject proj = cu.getJavaProject().getProject(); EJBJar jar = EarModuleManager.getEJBModuleExtension().getEJBJar(proj); if (null == jar) { jar = EarModuleManager.getEJBModuleExtension().getEJBJar(getEJBProjectFromEJBClientProject(proj)); } if (jar != null) { int index = cu.getElementName().indexOf('.'); String className = cu.getElementName(); if (index > 0) className = className.substring(0, index); JavaClass javaClass = (JavaClass) JavaRefFactory.eINSTANCE.reflectType(cu.getParent().getElementName(), className, jar.eResource().getResourceSet()); return jar.getEnterpriseBeanWithReference(javaClass); } return null; }
ResourceSet lookupSet = javaType.eResource().getResourceSet(); if (lookupSet != null) { if (!javaType.inheritsFrom(JavaRefFactory.eINSTANCE.reflectType(exceptionType, lookupSet).getWrapper())) { String[] parms = new String[1]; parms[0] = specifiedClassName;
/** * return the java servlet class for this servlet */ public JavaClass getServletClass() { JavaClass javaClass = null; String javaClassName = null; // Handle servlet case if (getWebType().isServletType()) javaClassName = ((ServletType)getWebType()).getClassName(); //Handle the JSP case else { String relPath = ((JSPType)getWebType()).getJspFile(); URI webAppURI = getWebApp().eResource().getURI(); javaClassName = webAppURI.segment(1)+"/"+webAppURI.segment(2)+relPath;//$NON-NLS-1$ } javaClass = (JavaClass) JavaRefFactory.eINSTANCE.reflectType(javaClassName,this); return javaClass; }