Class ProcessContainerExample


  • public class ProcessContainerExample
    extends Object
    This class is an executable main that loads an XTCE database file and dumps the contents of all the containers to STDOUT.

    The following is an example based on this demonstration class file. The class main() uses a built-in example database file in this larger package, instead of the "myfile.xml" used in the example code below.

     
     try {
    
    
         XTCEDatabase db = new XTCEDatabase( new File( "myfile.xml" ),
                                             false,  // skip XSD validation
                                             true,   // apply the XIncludes
                                             true ); // ReadOnly
    
         List<XTCETMContainer> containers = db.getContainers();
    
         for ( XTCETMContainer container : containers ) {
    
             XTCEContainerContentModel model =
                 new XTCEContainerContentModel( container,
                                                db.getSpaceSystemTree(),
                                                null,
                                                false );
    
             // get the size
             long sizeInBits = model.getTotalSize();
    
             // for demonstration, get the parameters in the container
             List<XTCEContainerContentEntry> entries =
                 model.getContentList();
    
             for ( XTCEContainerContentEntry entry : entries ) {
    
                 // skip content entries that are not actually used because
                 // the conditional include is false
                 if ( entry.isCurrentlyInUse() == false ) {
                     continue;
                 }
    
                 // print a message based on the type of entry
                 switch ( entry.getEntryType() ) {
    
                     case PARAMETER:
                         System.out.println( entry.getEntryTypeString() +
                                             ": " +
                                             entry.getParameter().getName() );
                         break;
    
                     case ARGUMENT:
                         System.out.println( entry.getEntryTypeString() +
                                             ": " +
                                             entry.getArgument().getName() );
                         break;
    
                     case CONSTANT:
                         System.out.println( entry.getEntryTypeString() +
                                             ": " +
                                             entry.getValue() );
                         break;
    
                     case CONTAINER:
                         // ignore for this purpose
                         break;
    
                     default:
                         break;
    
                 }
    
             }
    
             System.out.println( "Total Size: " +
                                 Long.toString( sizeInBits ) +
                                 " bits" );
    
         }
    
         System.out.println( "Done" );
    
     } catch ( Exception ex ) {
    
         System.out.println( "Exception: " + ex.getLocalizedMessage() );
         ex.printStackTrace();
    
     }
     
     
    Author:
    David Overeem
    • Constructor Detail

      • ProcessContainerExample

        public ProcessContainerExample()
    • Method Detail

      • main

        public static void main​(String[] args)
        Parameters:
        args - the command line arguments