예제 #1
0
 /** Returns the path of a schema, appending the name of a table if not null. */
 public static List<String> path(Schema schema, String name) {
   final List<String> list = new ArrayList<String>();
   if (name != null) {
     list.add(name);
   }
   for (Schema s = schema; s != null; s = s.getParentSchema()) {
     if (s.getParentSchema() != null || !s.getName().equals("")) {
       // Omit the root schema's name from the path if it's the empty string,
       // which it usually is.
       list.add(s.getName());
     }
   }
   return ImmutableList.copyOf(Lists.reverse(list));
 }
예제 #2
0
 /** Returns the root schema. */
 public static Schema root(Schema schema) {
   for (Schema s = schema; ; ) {
     Schema previous = s;
     s = s.getParentSchema();
     if (s == null) {
       return previous;
     }
   }
 }