blob: a6b3e398c9cb5cd6ce7cb51bc9c31e5a67230deb (
plain) (
tree)
|
|
package org.openslx.libvirt.xml;
import java.io.File;
import java.io.InputStream;
/**
* Collection of resource utils for a Libvirt XML document.
*
* @author Manuel Bentele
* @version 1.0
*/
public final class LibvirtXmlResources
{
/**
* File path prefix of the absolute path to the libvirt resource folder in a *.jar file.
*/
private static final String LIBVIRT_PREFIX_PATH = File.separator + "libvirt";
/**
* File path prefix of the absolute path to the libosinfo resource folder in a *.jar file.
*/
private static final String LIBOSINFO_PREFIX_PATH = File.separator + "libvirt" + File.separator + "libosinfo";
/**
* File path prefix of the absolute path to the libvirt XSL resource folder in a *.jar file.
*/
private static final String LIBVIRT_PREFIX_PATH_XSL = LIBVIRT_PREFIX_PATH + File.separator + "xsl";
/**
* File path prefix of the absolute path to the libvirt RNG resource folder in a *.jar file.
*/
private static final String LIBVIRT_PREFIX_PATH_RNG = LIBVIRT_PREFIX_PATH + File.separator + "rng";
/**
* File path prefix of the absolute path to the libosinfo RNG resource folder in a *.jar file.
*/
private static final String LIBOSINFO_PREFIX_PATH_RNG = LIBOSINFO_PREFIX_PATH + File.separator + "rng";
/**
* File path prefix of the absolute path to the libosinfo XML resource folder in a *.jar file.
*/
private static final String LIBOSINFO_PREFIX_PATH_XML = LIBOSINFO_PREFIX_PATH + File.separator + "xml";
/**
* Returns a Libvirt resource as stream.
*
* @param prefix file path of the Libvirt resource in the resources *.jar folder.
* @param fileName file name of the Libvirt resource in the resources *.jar folder.
* @return Libvirt resource as stream.
*/
private static InputStream getLibvirtResource( String prefix, String fileName )
{
final String path = prefix + File.separator + fileName;
return LibvirtXmlResources.class.getResourceAsStream( path );
}
/**
* Returns a Libvirt XSL resource as stream.
*
* @param libvirtXslFileName file name of the XSL resource in the resources *.jar folder.
* @return Libvirt XSL resource as stream.
*/
public static InputStream getLibvirtXsl( String libvirtXslFileName )
{
return LibvirtXmlResources.getLibvirtResource( LibvirtXmlResources.LIBVIRT_PREFIX_PATH_XSL, libvirtXslFileName );
}
/**
* Returns a Libvirt RNG schema resource as stream.
*
* @param libvirtRngFileName file name of the RNG schema resource in the resources *.jar folder.
* @return Libvirt RNG schema resource as stream.
*/
public static InputStream getLibvirtRng( String libvirtRngFileName )
{
return LibvirtXmlResources.getLibvirtResource( LibvirtXmlResources.LIBVIRT_PREFIX_PATH_RNG, libvirtRngFileName );
}
/**
* Returns a libosinfo RNG schema resource as stream.
*
* @param libosInfoRngFileName file name of the RNG schema resource in the resources *.jar
* folder.
* @return libosinfo RNG schema resource as stream.
*/
public static InputStream getLibOsInfoRng( String libosInfoRngFileName )
{
return LibvirtXmlResources.getLibvirtResource( LibvirtXmlResources.LIBOSINFO_PREFIX_PATH_RNG,
libosInfoRngFileName );
}
/**
* Returns a libosinfo XML resource as stream.
*
* @param libosInfoXmlFileName file name of the XML resource in the resources *.jar folder.
* @return libosinfo XML resource as stream.
*/
public static InputStream getLibOsInfoXml( String libosInfoXmlFileName )
{
return LibvirtXmlResources.getLibvirtResource( LibvirtXmlResources.LIBOSINFO_PREFIX_PATH_XML,
libosInfoXmlFileName );
}
}
|