1 /* 2 * Copyright 2011-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.util.lang.classpath; 17 18 import java.util.Collections; 19 import java.util.List; 20 21 /** 22 * Supports listing of class path elements for protocols <code>jar</code> and 23 * <code>file</code>. 24 */ 25 public final class JarAndFileClassPathListing implements ClassPathListing 26 { 27 // ********************************* Fields ********************************* 28 29 // --- constants ------------------------------------------------------------ 30 31 // --- members -------------------------------------------------------------- 32 33 // ****************************** Initializer ******************************* 34 35 // ****************************** Constructors ****************************** 36 37 // ****************************** Inner Classes ***************************** 38 39 // ********************************* Methods ******************************** 40 41 // --- init ----------------------------------------------------------------- 42 43 // --- get&set -------------------------------------------------------------- 44 45 // --- business ------------------------------------------------------------- 46 47 @Override 48 public List<String> list(final ClassPathContext context, 49 final String resourcePath) throws NullPointerException, 50 IllegalArgumentException 51 { 52 try 53 { 54 final ClassPathDirectoryListing delegate = 55 new ClassPathDirectoryListing(context); 56 return delegate.list(resourcePath); 57 } 58 catch (final IllegalArgumentException e) 59 { 60 return Collections.emptyList(); 61 } 62 } 63 64 // --- object basics -------------------------------------------------------- 65 66 }