mil.dod.th.ose.shared/src/mil/dod/th/ose/shared/protoconverter/JaxbConverter.java
private static Class<? extends Message> findProtoClass(final Class<?> jaxbClass) throws ObjectConverterException
    {
        //split on the core package
        final String jaxbPackageFragment = jaxbClass.getName().split("mil.dod.th.core")[1];

        final String clazz = jaxbClass.getSimpleName();
        //the ending part of the jaxb package that matches the proto package
        final String splitPackage = jaxbPackageFragment.split("[A-Z].")[0];

        //Types package partition.
        final String typePackage = ".types.";
        //Remote package.
        final String remotePackage = "mil.dod.th.remote.lexicon";
        //Inner class designator.
        final String innerPackageDesignator = "$";
        //Generated proto file suffix.
        final String GEN_SUFFIX = "Gen";
        
        //the proto fqn class that is to found
        final String protoEquivFullyQualifiedClass;
        
        //the 'types' package contents are defined by the SharedTypes.xsd, this then becomes the SharedTypesGen,
        //from just the package and the jaxb class (xsd complex/simple types) there is not an easy way to derive the
        //package and outer class.
        if (typePackage.equals(splitPackage))
        {
            // The core.types package is defined in the SharedTypes.xsd, thus the proto derivative below.
            protoEquivFullyQualifiedClass = remotePackage + splitPackage + "SharedTypes"
                    + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        else if (splitPackage.startsWith(typePackage))
        {
            // the 'types' package contents are defined by a Xtypes.xsd, this then becomes the xTypesGen,
            // by transposing the last two package partitions the xsd encompassing type and the proto Gen type can
            // be derived.
            // TD: this is not infallible if there are further packages within the packages currently defined this
            // will break. There is not an way to get the XSD from which the jaxb classes came, but an improvement
            // might be making the XSD class known somehow.
            final String[] splitPackageUp = splitPackage.split("\\.");
            final StringBuffer switchPackOutterClass = new StringBuffer();
            // reverse the package sections, and you get the type, i.e. ...types.monkey can be expected to be derived
            // from MonkeyTypes.xsd and thus MonkeyTypesGen for proto concerns.
            for (int i = splitPackageUp.length - 1; i > 0; i--)
            {
                switchPackOutterClass.append(
                        CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, splitPackageUp[i]));
            }
            protoEquivFullyQualifiedClass = remotePackage + splitPackage + switchPackOutterClass
                    + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        //mission package doesn't match the types structure, so has to be handled differently
        // TD should be able to look up XSD parent
        else if (MissionProgramSchedule.class.getSimpleName().equals(clazz))
        {
            //The schedule is defined in the parameters xsd, thus the proto derivative below.
            protoEquivFullyQualifiedClass = remotePackage + splitPackage + "MissionProgramParameters"
                        + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        else
        {
            protoEquivFullyQualifiedClass = remotePackage + jaxbPackageFragment 
                    + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        
        try
        {
            @SuppressWarnings("unchecked")
            final Class<? extends Message> messageClassToReturn = (Class<? extends Message>)
                    Class.forName(protoEquivFullyQualifiedClass, true, 
                    mil.dod.th.remote.lexicon.observation.types.ObservationGen.Observation.class.getClassLoader());
            //return here so suppression can be used on var
            return messageClassToReturn;
        }
        catch (final ClassNotFoundException e)
        {
            throw new ObjectConverterException(e);
        }
    }
/**
     * Find the proto class associated with the given jaxb class.
     * <br>
     * <br>
     * <b>NOTE: This method is not able to find all jaxb classes. Specifically
     * classes that are defined in a parent xGen class that does not match the jaxb objects simple
     * name, for example the proto message class for mil.dod.th.core.asset.capability.CommandCapabilities
     * will not be found without being in a mil.dod.th.core.asset.capability.AssetCapabilities jaxb
     * object. This is because there is currently no way to know that the 
     * mil.dod.th.core.asset.capability.CommandCapabilities proto message
     * equivalent is in mil.dod.th.remote.lexicon.asset.capability.AssetCapabilitiesGen.CommandCapabilities.
     * </b>
     * 
     * @param jaxbClass
     *      the jaxb class to find the proto equivalent of
     * @return
     *      the proto message class
     * @throws ObjectConverterException
     *      if the class cannot be found
     */
Find the proto class associated with the given jaxb class.


NOTE: This method is not able to find all jaxb classes. Specifically
classes that are defined in a parent xGen class that does not match the jaxb objects simple
name, for example the proto message class for mil.dod.th.core.asset.capability.CommandCapabilities
will not be found without being in a mil.dod.th.core.asset.capability.AssetCapabilities jaxb
object. This is because there is currently no way to know that the
mil.dod.th.core.asset.capability.CommandCapabilities proto message
equivalent is in mil.dod.th.remote.lexicon.asset.capability.AssetCapabilitiesGen.CommandCapabilities.

@param jaxbClass
the jaxb class to find the proto equivalent of
@return
the proto message class
@throws ObjectConverterException
if the class cannot be found
Find the proto class associated with the given jaxb class . NOTE : This method is not able to find all jaxb classes . Specifically classes that are defined in a parent xGen class that does not match the jaxb objects simple name for example the proto message class for mil . dod . th . core . asset . capability . CommandCapabilities will not be found without being in a mil . dod . th . core . asset . capability . AssetCapabilities jaxb object . This is because there is currently no way to know that the mil . dod . th . core . asset . capability . CommandCapabilities proto message equivalent is in mil . dod . th . remote . lexicon . asset . capability . AssetCapabilitiesGen . CommandCapabilities . @param jaxbClass the jaxb class to find the proto equivalent of @return the proto message class @throws ObjectConverterException if the class cannot be found
private static Class<? extends Message> findProtoClass(final Class<?> jaxbClass) throws ObjectConverterException
    {
        final String jaxbPackageFragment = jaxbClass.getName().split("mil.dod.th.core")[1];
        final String clazz = jaxbClass.getSimpleName();
        final String splitPackage = jaxbPackageFragment.split("[A-Z].")[0];
        final String typePackage = ".types.";
        final String remotePackage = "mil.dod.th.remote.lexicon";
        final String innerPackageDesignator = "$";
        final String GEN_SUFFIX = "Gen";
        final String protoEquivFullyQualifiedClass;
        if (typePackage.equals(splitPackage))
        {
            protoEquivFullyQualifiedClass = remotePackage + splitPackage + "SharedTypes"
                    + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        else if (splitPackage.startsWith(typePackage))
        {
            final String[] splitPackageUp = splitPackage.split("\\.");
            final StringBuffer switchPackOutterClass = new StringBuffer();
            for (int i = splitPackageUp.length - 1; i > 0; i--)
            {
                switchPackOutterClass.append(
                        CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, splitPackageUp[i]));
            }
            protoEquivFullyQualifiedClass = remotePackage + splitPackage + switchPackOutterClass
                    + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        else if (MissionProgramSchedule.class.getSimpleName().equals(clazz))
        {
            protoEquivFullyQualifiedClass = remotePackage + splitPackage + "MissionProgramParameters"
                        + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        else
        {
            protoEquivFullyQualifiedClass = remotePackage + jaxbPackageFragment 
                    + GEN_SUFFIX + innerPackageDesignator + clazz;
        }
        try
        {
            @SuppressWarnings("unchecked")
            final Class<? extends Message> messageClassToReturn = (Class<? extends Message>)
                    Class.forName(protoEquivFullyQualifiedClass, true, 
                    mil.dod.th.remote.lexicon.observation.types.ObservationGen.Observation.class.getClassLoader());
            return messageClassToReturn;
        }
        catch (final ClassNotFoundException e)
        {
            throw new ObjectConverterException(e);
        }
    }
private static Class < ? extends Message > findProtoClass ( final Class < ? > jaxbClass ) throws ObjectConverterException { final String jaxbPackageFragment = jaxbClass . getName ( ) . split ( "mil.dod.th.core" ) [ 1 ] ; final String clazz = jaxbClass . getSimpleName ( ) ; final String splitPackage = jaxbPackageFragment . split ( "[A-Z]." ) [ 0 ] ; final String typePackage = ".types." ; final String remotePackage = "mil.dod.th.remote.lexicon" ; final String innerPackageDesignator = "$" ; final String GEN_SUFFIX = "Gen" ; final String protoEquivFullyQualifiedClass ; if ( typePackage . equals ( splitPackage ) ) { protoEquivFullyQualifiedClass = remotePackage + splitPackage + "SharedTypes" + GEN_SUFFIX + innerPackageDesignator + clazz ; } else if ( splitPackage . startsWith ( typePackage ) ) { final String [ ] splitPackageUp = splitPackage . split ( "\\." ) ; final StringBuffer switchPackOutterClass = new StringBuffer ( ) ; for ( int i = splitPackageUp . length - 1 ; i > 0 ; i -- ) { switchPackOutterClass . append ( CaseFormat . LOWER_CAMEL . to ( CaseFormat . UPPER_CAMEL , splitPackageUp [ i ] ) ) ; } protoEquivFullyQualifiedClass = remotePackage + splitPackage + switchPackOutterClass + GEN_SUFFIX + innerPackageDesignator + clazz ; } else if ( MissionProgramSchedule . class . getSimpleName ( ) . equals ( clazz ) ) { protoEquivFullyQualifiedClass = remotePackage + splitPackage + "MissionProgramParameters" + GEN_SUFFIX + innerPackageDesignator + clazz ; } else { protoEquivFullyQualifiedClass = remotePackage + jaxbPackageFragment + GEN_SUFFIX + innerPackageDesignator + clazz ; } try { @ SuppressWarnings ( "unchecked" ) final Class < ? extends Message > messageClassToReturn = ( Class < ? extends Message > ) Class . forName ( protoEquivFullyQualifiedClass , true , mil . dod . th . remote . lexicon . observation . types . ObservationGen . Observation . class . getClassLoader ( ) ) ; return messageClassToReturn ; } catch ( final ClassNotFoundException e ) { throw new ObjectConverterException ( e ) ; } }
Find the proto class associated with the given jaxb class.
Find the proto class associated with the given jaxb class .
//split on the core package //the ending part of the jaxb package that matches the proto package //Types package partition. //Remote package. //Inner class designator. //Generated proto file suffix. //the proto fqn class that is to found //the 'types' package contents are defined by the SharedTypes.xsd, this then becomes the SharedTypesGen, //from just the package and the jaxb class (xsd complex/simple types) there is not an easy way to derive the //package and outer class. // The core.types package is defined in the SharedTypes.xsd, thus the proto derivative below. // the 'types' package contents are defined by a Xtypes.xsd, this then becomes the xTypesGen, // by transposing the last two package partitions the xsd encompassing type and the proto Gen type can // be derived. // TD: this is not infallible if there are further packages within the packages currently defined this // will break. There is not an way to get the XSD from which the jaxb classes came, but an improvement // might be making the XSD class known somehow. // reverse the package sections, and you get the type, i.e. ...types.monkey can be expected to be derived // from MonkeyTypes.xsd and thus MonkeyTypesGen for proto concerns. //mission package doesn't match the types structure, so has to be handled differently // TD should be able to look up XSD parent //The schedule is defined in the parameters xsd, thus the proto derivative below. //return here so suppression can be used on var