/** * A mere wrapper on the static <code>JaxbUtil.getJavaClassName</code>. * * @param jaxbPackage the JAXB package name from which a java class name is * to be derived * @param jaxbTypeName the JAXB type name from which a java class name is to * be derived * @return a class name (including package name) that the JAXB class is * hiding or the JAXB class itself if it is not hiding a POJO. * @throws HostException if deriving a java class name fails */ public String getJavaClassName(final String jaxbPackage, final String jaxbTypeName) throws HostException { return BindingUtil.getJavaClassName(jaxbPackage, jaxbTypeName); }
/** * Retrieves the XML namespace associated with a JAXB element. * * @param jaxbPackageName a JAXB element package name * @param jaxbTypeName a JAXB element type name * @return the XML namespace * @throws HostException if retrieving XML element name fails */ public String getXmlNamespace(final String jaxbPackageName, final String jaxbTypeName) throws HostException { return BindingUtil.getXmlNamespace(jaxbPackageName, jaxbTypeName); }
/** * Builds a binding type name using the associated jaxb type name. * * @param binding the binding for which the binding type is to be returned * @return the binding type name */ public String getCoxbTypeName(final ICobolBinding binding) { return BindingUtil.getCoxbTypeName(binding); }
/** * @param binding a bound element * @return the jaxb variable name of the element */ public String getFieldName(final ICobolBinding binding) { return FIELD_NAMES_PREFIX + BindingUtil.getFieldName(binding); }
/** * Retrieve the bound object type. Since there are more precise methods for * complex objects, this will apply for simple objects. * <p/> * For nested classes, the jaxb type name would have the form * parentType$nestedType. We change that here to parentType.nestedType * because this form lends itself to to direct usage in java sentences such * as parentType.nestedType.class. * * @param binding a binding element * @return the bound object type name */ public String getBoundTypeName(final ICobolBinding binding) { String boundTypeName = BindingUtil.getJaxbTypeName(binding); if (boundTypeName != null) { boundTypeName = boundTypeName.replace("$", "."); } return boundTypeName; }
/** * Loads the object factory class using the current class loader assuming * the JAXB classes are available in the current classpath and returns a new * instance of it. * * @param packageName the package containing a JAXB Object Factory * @return a JAXB Object factory */ protected Object getObjectFactory(final String packageName) { Object jaxbObjectFactory = null; if (packageName == null || packageName.length() == 0) { throw (new BuildException("You must provide a JAXB package name.")); } try { jaxbObjectFactory = BindingUtil.newJaxbObjectFactory(packageName); } catch (SecurityException e) { throw new BuildException(e); } catch (IllegalArgumentException e) { throw new BuildException(e); } catch (CobolBindingException e) { throw new BuildException(e); } return jaxbObjectFactory; }
/** * Return the maximum host byte length for a COBOL-annotated JAXB class. * <p/> * Here we assume binding classes were generated so we can use their ability * to deliver the byte length without going through a JAXB annotation * introspection. * * @param jaxbPackageName the JAXB package name * @param jaxbClassName the JAXB class name of the object for which byte * length must be returned * @return the byte length * @throws HostException if byte length calculation failed */ public long getByteLength( final String jaxbPackageName, final String jaxbClassName) throws HostException { IHostTransformers tf = BindingUtil.newTransformers(jaxbPackageName, jaxbClassName); return tf.getHostToJava().getByteLength(); }
/** * Creates get/set method name. * * @param prefix either get or set * @param binding the element * @return a method name to either get or set this element */ protected String getterSetterMethodName(final String prefix, final ICobolBinding binding) { String fieldName = BindingUtil.getFieldName(binding); if (fieldName == null || fieldName.length() == 0) { throw new IllegalArgumentException(fieldName); } if (fieldName.length() == 1) { return prefix + fieldName.toUpperCase(Locale.getDefault()); } return prefix + fieldName.substring(0, 1).toUpperCase(Locale.getDefault()) + fieldName.substring(1, fieldName.length()); }
/** * Returns a generic type to simplify code generation. * * @param binding a bound element * @return a generic type */ public String getGenericType(final ICobolBinding binding) { if (binding instanceof ICobolComplexBinding) { return "complex"; } if (binding instanceof ICobolChoiceBinding) { return "choice"; } if (binding instanceof ICobolArrayComplexBinding) { return "complexArray"; } if (ClassUtil.isEnum(BindingUtil.getJaxbTypeName(binding))) { return "enum"; } else { return "simple"; } }
.newJaxbObjectFactory(getJaxbPackageName());
/** * @return JAXB namespace of complex type * @throws HostException if namespace cannot be detected from annotations */ public String getJaxbNamespace() throws HostException { return BindingUtil.getXmlNamespace(getJaxbPackageName(), getJaxbType()); }
/** * A mere wrapper on the static <code>JaxbUtil.getJavaClassName</code>. * * @param jaxbPackage the JAXB package name from which a java class name * is to be derived * @param jaxbTypeName the JAXB type name from which a java class name * is to be derived * @return a class name (including package name) that the JAXB class * is hiding or the JAXB class itself if it is not hiding a POJO. * @throws HostException if deriving a java class name fails */ public String getJavaClassName( final String jaxbPackage, final String jaxbTypeName) throws HostException { return BindingUtil.getJavaClassName(jaxbPackage, jaxbTypeName); }
/** * Get the binding type for the inner item of a complex array. * * @param binding the binding for which the binding type is to be returned * @return the binding type name */ public String getItemCoxbTypeName(final ICobolArrayComplexBinding binding) { return BindingUtil.getCoxbTypeName(binding.getComplexItemBinding()); }