# 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 8: Get an existing object

This is an example of how to read an object from the SAS Metadata Server. This example will retrieve an existing PhysicalTable along with its attributes and a set of associations.

       /**
        * This method retrieves detailed information for a specific PhysicalTable
        * @param table the table to retrieve
        */
       public void getTableInformation(PhysicalTable table)
       {
          try
          {
             // Print a descriptive message about the request.
             System.out.println("\nRetrieving information for a specific PhysicalTable");

             // Create a template to retreive detailed information for this table
             String template = "<Templates>" +
                                  "<PhysicalTable>" +
                                    "<Columns/>" +
                                    "<Notes/>" +
                                    "<Keywords/>" +
                                  "</PhysicalTable>" +
                                "</Templates>";

             // Use the OMI_ALL_SIMPLE flag to get all attributes for each table returned
             int flags = MetadataUtil.OMI_GET_METADATA | MetadataUtil.OMI_ALL_SIMPLE |
                            MetadataUtil.OMI_TEMPLATE;
             table = (PhysicalTable) MetadataUtil.getMetadataAllDepths
                    (table,
                     null,
                     null,
                     template,
                     flags);

             // Print information about the table
             System.out.println("Table attributes: ");
             System.out.println("  Name = " + table.getName());
             System.out.println("  Id = " + table.getId());
             System.out.println("  Description = " + table.getDesc());
             System.out.println("  Created Date = " + table.getMetadataCreated());
             System.out.println("Table associations: ");
             System.out.println("  Number of Columns = " + table.getColumns().size());
             System.out.println("  Number of Keywords = " + table.getKeywords().size());
             System.out.println("  Number of Notes = " + table.getNotes().size());
          }
          catch (MdException e)
          {
             e.printStackTrace();
          }
       }