Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 82   Methods: 2
NCLOC: 39   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ListCollections.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Licensed to the Apache Software Foundation (ASF) under one or more
 3    * contributor license agreements. See the NOTICE file distributed with
 4    * this work for additional information regarding copyright ownership.
 5    * The ASF licenses this file to You under the Apache License, Version 2.0
 6    * (the "License"); you may not use this file except in compliance with
 7    * the License. You may obtain a copy of the License at
 8    *
 9    * http://www.apache.org/licenses/LICENSE-2.0
 10    *
 11    * Unless required by applicable law or agreed to in writing, software
 12    * distributed under the License is distributed on an "AS IS" BASIS,
 13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14    * See the License for the specific language governing permissions and
 15    * limitations under the License.
 16    *
 17    * $Id: ListCollections.java 578602 2007-09-23 20:33:31Z natalia $
 18    */
 19   
 20    package org.apache.xindice.tools.command;
 21   
 22    import org.apache.xindice.tools.XMLTools;
 23   
 24    import org.xmldb.api.DatabaseManager;
 25    import org.xmldb.api.base.Collection;
 26   
 27    /**
 28    * ListCollections.java is designed to let the user list all Collections from
 29    * a parent Collection or a nested Collection.
 30    *
 31    * NOTE: Collection names are not returned in any specific order
 32    *
 33    * @version $Revision: 578602 $, $Date: 2007-09-23 13:33:31 -0700 (Sun, 23 Sep 2007) $
 34    */
 35    public class ListCollections extends Command {
 36   
 37  0 public boolean execute(XMLTools.Config table) throws Exception {
 38   
 39  0 if (table.getString(XMLTools.COLLECTION) == null) {
 40  0 System.out.println("ERROR : Collection context required");
 41  0 return false;
 42    }
 43   
 44  0 Collection col = null;
 45  0 try {
 46    // list the COLLECTIONURI + The collection passed in
 47  0 String colstring = normalizeCollectionURI(table.getString(XMLTools.COLLECTION),
 48    table.getBoolean(XMLTools.LOCAL));
 49   
 50    // Get a Collection reference
 51  0 col = DatabaseManager.getCollection(colstring);
 52  0 if (col == null) {
 53  0 System.out.println("ERROR : Collection not found!");
 54  0 return false;
 55    }
 56   
 57  0 String[] colarray = col.listChildCollections();
 58  0 System.out.println();
 59   
 60  0 for (int i = 0; i < colarray.length; i++) {
 61  0 System.out.println("\t" + colarray[i]);
 62    }
 63   
 64  0 System.out.println("\nTotal collections: " + colarray.length);
 65    } finally {
 66    // Close collection objects and release
 67  0 if (col != null) {
 68  0 col.close();
 69    }
 70    }
 71  0 return true;
 72    }
 73   
 74  0 public void usage() {
 75  0 System.out.println("Format: xindice lc -c <context> [-l [-d <path>]] [-v]");
 76  0 System.out.println();
 77  0 System.out.println("Lists child collections in a specific collection");
 78  0 System.out.println();
 79    }
 80    }
 81   
 82