line.separator
*/
public final static String NEW_LINE = System.getProperty("line.separator");
/**
* Method creates indent string consisting of as many {@code TAB} characters as specified by {@code indentLevel} parameter
*
* @param indentLevel indentation level
* @return indentation string as specified by indentation level
*
*/
public static String createIndent(final int indentLevel) {
final char[] charData = new char[indentLevel * 4];
Arrays.fill(charData, ' ');
return String.valueOf(charData);
}
}
public static class Comparison {
/**
* The comparator comapres QName objects according to their publicly accessible attributes, in the following
* order of attributes:
*
* 1. namespace (not null String)
* 2. local name (not null String)
*/
public static final Comparatorwsit-{configFileIdentifier}.xml
. Must not be {@code null}.
* @return generated config file resource name
* @throw PolicyException If configFileIdentifier is null.
*/
public static String generateFullName(final String configFileIdentifier) throws PolicyException {
if (configFileIdentifier != null) {
final StringBuffer buffer = new StringBuffer("wsit-");
buffer.append(configFileIdentifier).append(".xml");
return buffer.toString();
} else {
throw new PolicyException(LocalizationMessages.WSP_0080_IMPLEMENTATION_EXPECTED_NOT_NULL());
}
}
/**
* Returns a URL pointing to the given config file. The file name is
* looked up as a resource from a ServletContext.
*
* May return null if the file can not be found.
*
* @param configFileName The name of the file resource
* @param context A ServletContext object. May not be null.
*/
public static URL loadFromContext(final String configFileName, final Object context) {
return Reflection.invoke(context, "getResource", URL.class, configFileName);
}
/**
* Returns a URL pointing to the given config file. The file is looked up as
* a resource on the classpath.
*
* May return null if the file can not be found.
*
* @param configFileName the name of the file resource. May not be {@code null}.
*/
public static URL loadFromClasspath(final String configFileName) {
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
return ClassLoader.getSystemResource(configFileName);
} else {
return cl.getResource(configFileName);
}
}
}
/**
* Wrapper for ServiceFinder class which is not part of the Java SE yet.
*/
public static class ServiceProvider {
/**
* Locates and incrementally instantiates the available providers of a
* given service using the given class loader.
*
* This method transforms the name of the given service class into a * provider-configuration filename as described above and then uses the * {@code getResources} method of the given class loader to find all * available files with that name. These files are then read and parsed to * produce a list of provider-class names. Eventually each provider class is * instantiated and array of those instances is returned. *
*Because it is possible for extensions to be installed into a running * Java virtual machine, this method may return different results each time * it is invoked.
*
* @param serviceClass The service's abstract service class. Must not be {@code null}.
* @param loader The class loader to be used to load provider-configuration files
* and instantiate provider classes, or {@code null} if the system
* class loader (or, failing that the bootstrap class loader) is to
* be used
* @throws NullPointerException in case {@code service} input parameter is {@code null}.
* @throws ServiceConfigurationError If a provider-configuration file violates the specified format
* or names a provider class that cannot be found and instantiated
* @see #load(Class)
*/
public static
* ClassLoader cl = Thread.currentThread().getContextClassLoader();
* return PolicyUtils.ServiceProvider.load(service, cl);
*
*
* @param serviceClass The service's abstract service class. Must not be {@code null}.
*
* @throws NullPointerException in case {@code service} input parameter is {@code null}.
* @throws ServiceConfigurationError If a provider-configuration file violates the specified format
* or names a provider class that cannot be found and instantiated
* @see #load(Class, ClassLoader)
*/
public static