# How to Use the SAS Java Metadata Interface

- Package Description
- Example 1: Server Connection
- Example 2: Get Repositories
- Example 3: Get Metadata Types
- Example 4: Create Objects
- Example 5: Read Objects
- Example 6: Delete Objects
- Example 7: Get all objects of a particular type
- Example 8: Get an existing object
- Sample Program

## Example 7: Get all objects of a particular type

This is an example of how to retrieve all objects of a particular metadata type in the SAS Metadata Repository. This method retrieves all PhysicalTables contained in the repository.

       /**
        * This method displays the PhysicalTable objects contained in repository
        * @param repository CMetadata identifies the repository from which to read
        * the objects.
        */
       public void displayAllTables(CMetadata repository)
       {
          try
          {
             // Print a descriptive message about the request.
             System.out.println("\nRetrieving all PhysicalTable objects contained in " +
                   " repository " + repository.getName());

             // Use the short Repository ID to pass in the method.
             String reposID = repository.getFQID();

             // We get a list of "PhysicalTable" objects.
             MdObjectStore store = MdObjectFactory.createObjectStore();

             // Use the OMI_ALL_SIMPLE flag to get all attributes for each table returned
             int flags = MetadataUtil.OMI_GET_METADATA | MetadataUtil.OMI_ALL_SIMPLE;
             List tables = MetadataUtil.getMetadataObjectsSubset
                    (store,
                    reposID,                         // Repository to Search
                    MetadataObjects.PHYSICALTABLE,   // Type to search for
                    flags,
                    "" );

             // Print information about them.
             Iterator iter = tables.iterator();
             while( iter.hasNext())
             {
                PhysicalTable ptable = (PhysicalTable)iter.next();
                System.out.println("PhysicalTable: " +
                                   ptable.getName() +
                                   ", " +
                                   ptable.getFQID() +
                                   ", " +
                                   ptable.getDesc());
             }

             // When finished, clean up the objects in the store if it is no longer
             // being used
             store.dispose();
          }
          catch (MdException e)
          {
             e.printStackTrace();
          }
       }