mil.dod.th.ose.jaxb.proto.converter/src/mil/dod/th/ose/jaxbprotoconverter/JaxbClassParser.java
private void handleRefImport(final ProtoField field, final Class<?> refClass) throws JaxbProtoConvertException  
    {
        //Get the proto message the field is within.
        final ProtoMessage protoMsg = field.getProtoMessage();
        //Get XSD type that represents the proto message the field is within.
        final XsdType msgXsdType = protoMsg.getXsdType();
        final ProtoFile protoFile = protoMsg.getProtoFile();
        final Set<String> imports = protoFile.getImports();
        
        final XsdType refXsdType;
        if (refClass.isEnum())
        {
            //If the reference type is an enumeration then attempt to retrieve the XSD type that represents the 
            //reference type based off the enumeration base type. Else, if there is no base enumeration type then
            //use the reference type to retrieve the XSD type that represents the enumeration.
            final Class<?> enumBaseClass = findEnumBaseClass(refClass);
            refXsdType = enumBaseClass != null ? findXsdType(enumBaseClass) : findXsdType(refClass);
        }
        else
        {
            //Get the XSD type that represents the reference type.
            refXsdType = findXsdType(refClass);
        }
        
        //If the reference XSD type is null then the field must reference a non-generated type.
        if (refXsdType == null)
        {
            final String elementName = field.getTypeRef().getName();
            //Check if there is a non-generated type that can be imported and add the appropriate import statement, 
            //otherwise throw an exception.
            if (m_ImportableMessages.containsKey(elementName))
            {
                imports.add(m_ImportableMessages.get(elementName));
            }
            else
            {
                throw new JaxbProtoConvertException(String.format("Reference type %s for message %s is not a known "
                        + "generated or non-generated type", refClass.getName(), protoMsg.getName()));
            }
        }
        //If the reference XSD type exists, then check to see if the message and reference type are located in the
        //different XSD files. If they are in different XSD files then an import statement is added.
        else if (!msgXsdType.getXsdFile().equals(refXsdType.getXsdFile()))
        {
            final String importStatement = buildImportStatement(refXsdType.getXsdFile());
            imports.add(importStatement);
        }
    }
/**
     * Method used to determine if an import statement needs to be added for the reference type field.
     * 
     * @param field
     *      Model that represents the field that is a reference to another message.
     * @param refClass
     *      Class type of the reference class.
     * @throws JaxbProtoConvertException
     *      Thrown if the reference type cannot be found. 
     */
Method used to determine if an import statement needs to be added for the reference type field.

@param field
Model that represents the field that is a reference to another message.
@param refClass
Class type of the reference class.
@throws JaxbProtoConvertException
Thrown if the reference type cannot be found.
Method used to determine if an import statement needs to be added for the reference type field . @param field Model that represents the field that is a reference to another message . @param refClass Class type of the reference class . @throws JaxbProtoConvertException Thrown if the reference type cannot be found .
private void handleRefImport(final ProtoField field, final Class<?> refClass) throws JaxbProtoConvertException  
    {
        final ProtoMessage protoMsg = field.getProtoMessage();
        final XsdType msgXsdType = protoMsg.getXsdType();
        final ProtoFile protoFile = protoMsg.getProtoFile();
        final Set<String> imports = protoFile.getImports();
        final XsdType refXsdType;
        if (refClass.isEnum())
        {
            final Class<?> enumBaseClass = findEnumBaseClass(refClass);
            refXsdType = enumBaseClass != null ? findXsdType(enumBaseClass) : findXsdType(refClass);
        }
        else
        {
            refXsdType = findXsdType(refClass);
        }
        if (refXsdType == null)
        {
            final String elementName = field.getTypeRef().getName();
            if (m_ImportableMessages.containsKey(elementName))
            {
                imports.add(m_ImportableMessages.get(elementName));
            }
            else
            {
                throw new JaxbProtoConvertException(String.format("Reference type %s for message %s is not a known "
                        + "generated or non-generated type", refClass.getName(), protoMsg.getName()));
            }
        }
        else if (!msgXsdType.getXsdFile().equals(refXsdType.getXsdFile()))
        {
            final String importStatement = buildImportStatement(refXsdType.getXsdFile());
            imports.add(importStatement);
        }
    }
private void handleRefImport ( final ProtoField field , final Class < ? > refClass ) throws JaxbProtoConvertException { final ProtoMessage protoMsg = field . getProtoMessage ( ) ; final XsdType msgXsdType = protoMsg . getXsdType ( ) ; final ProtoFile protoFile = protoMsg . getProtoFile ( ) ; final Set < String > imports = protoFile . getImports ( ) ; final XsdType refXsdType ; if ( refClass . isEnum ( ) ) { final Class < ? > enumBaseClass = findEnumBaseClass ( refClass ) ; refXsdType = enumBaseClass != null ? findXsdType ( enumBaseClass ) : findXsdType ( refClass ) ; } else { refXsdType = findXsdType ( refClass ) ; } if ( refXsdType == null ) { final String elementName = field . getTypeRef ( ) . getName ( ) ; if ( m_ImportableMessages . containsKey ( elementName ) ) { imports . add ( m_ImportableMessages . get ( elementName ) ) ; } else { throw new JaxbProtoConvertException ( String . format ( "Reference type %s for message %s is not a known " + "generated or non-generated type" , refClass . getName ( ) , protoMsg . getName ( ) ) ) ; } } else if ( ! msgXsdType . getXsdFile ( ) . equals ( refXsdType . getXsdFile ( ) ) ) { final String importStatement = buildImportStatement ( refXsdType . getXsdFile ( ) ) ; imports . add ( importStatement ) ; } }
Method used to determine if an import statement needs to be added for the reference type field.
Method used to determine if an import statement needs to be added for the reference type field .
//Get the proto message the field is within. //Get XSD type that represents the proto message the field is within. //If the reference type is an enumeration then attempt to retrieve the XSD type that represents the  //reference type based off the enumeration base type. Else, if there is no base enumeration type then //use the reference type to retrieve the XSD type that represents the enumeration. //Get the XSD type that represents the reference type. //If the reference XSD type is null then the field must reference a non-generated type. //Check if there is a non-generated type that can be imported and add the appropriate import statement,  //otherwise throw an exception. //If the reference XSD type exists, then check to see if the message and reference type are located in the //different XSD files. If they are in different XSD files then an import statement is added.