jsyntaxpane.util
Class JarServiceProvider

java.lang.Object
  extended by jsyntaxpane.util.JarServiceProvider

public class JarServiceProvider
extends java.lang.Object

Author:
subwiz, Ayman Al-Sairafi

Field Summary
static java.lang.String SERVICES_ROOT
           
 
Method Summary
static java.io.InputStream findResource(java.lang.String url)
          Attempt to find a location url.
static java.io.InputStream findResource(java.lang.String url, java.lang.ClassLoader cl)
          Attempt to find a location url.
static java.util.List<java.lang.Object> getServiceProviders(java.lang.Class<?> cls)
          Return an Object array from the file in META-INF/resources/{classname}
static java.util.List<java.lang.String> readLines(java.lang.String url)
          Read the given URL and returns a List of Strings for each input line Each line will not have the line terminator.
static java.util.Properties readProperties(java.lang.Class<?> clazz)
          Read a file in the META-INF/services location.
static java.util.Properties readProperties(java.lang.String name)
          Read a file in the META-INF/services named name appended with ".properties" If no file is found, then a an empty Property instance will be returned
static java.util.Properties readProperties(java.lang.String name, java.util.Locale locale)
          Read language specific files in the META-INF/services named name appended with ".properties".
static java.util.Map<java.lang.String,java.lang.String> readStringsMap(java.lang.String name)
          Read a file in the META-INF/services named name appended with ".properties", and returns it as a Map If no file is found, then a an empty Property instance will be returned
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICES_ROOT

public static final java.lang.String SERVICES_ROOT
See Also:
Constant Field Values
Method Detail

getServiceProviders

public static java.util.List<java.lang.Object> getServiceProviders(java.lang.Class<?> cls)
                                                            throws java.io.IOException
Return an Object array from the file in META-INF/resources/{classname}

Parameters:
cls -
Returns:
Throws:
java.io.IOException

readProperties

public static java.util.Properties readProperties(java.lang.Class<?> clazz)
Read a file in the META-INF/services location. File name will be fully qualified classname, in all lower-case, appended with ".properties" If no file is found, then a an empty Property instance will be returned

Parameters:
clazz -
Returns:
Property file read.

readProperties

public static java.util.Properties readProperties(java.lang.String name)
Read a file in the META-INF/services named name appended with ".properties" If no file is found, then a an empty Property instance will be returned

Parameters:
name - name of file (use dots to separate subfolders).
Returns:
Property file read.

readProperties

public static java.util.Properties readProperties(java.lang.String name,
                                                  java.util.Locale locale)
Read language specific files in the META-INF/services named name appended with ".properties". The contents of the files are merged as follows: Example: You have three files:

readStringsMap

public static java.util.Map<java.lang.String,java.lang.String> readStringsMap(java.lang.String name)
Read a file in the META-INF/services named name appended with ".properties", and returns it as a Map If no file is found, then a an empty Property instance will be returned

Parameters:
name - name of file (use dots to separate subfolders).
Returns:
Map of keys and values

readLines

public static java.util.List<java.lang.String> readLines(java.lang.String url)
Read the given URL and returns a List of Strings for each input line Each line will not have the line terminator. The resource is searched in /META-INF/services/url, then in url, then the url is treated as a location in the current classpath and an attempt to read it from that location is done.

Parameters:
url - location of file to read
Returns:
List of Strings for each line read. or EMPTY_LIST if URL is not found

findResource

public static java.io.InputStream findResource(java.lang.String url,
                                               java.lang.ClassLoader cl)
Attempt to find a location url. The following locations are searched in sequence: url, SERVICES_ROOT/url all classpath/url

Parameters:
url -
cl - classloader
Returns:
InputSTream at that location, or null if not found
See Also:
findResource(java.lang.String)

findResource

public static java.io.InputStream findResource(java.lang.String url)
Attempt to find a location url. The following locations are searched in sequence: url, SERVICES_ROOT/url all classpath/url The System ClassLoader is used.

Parameters:
url -
Returns:
InputSTream at that location, or null if not found
See Also:
findResource(java.lang.String, java.lang.ClassLoader)