org.apache.directory.api.ldap.schemaextractor.impl
Class DefaultSchemaLdifExtractor

java.lang.Object
  extended by org.apache.directory.api.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor
All Implemented Interfaces:
SchemaLdifExtractor

public class DefaultSchemaLdifExtractor
extends Object
implements SchemaLdifExtractor

Extracts LDIF files for the schema repository onto a destination directory.

Author:
Apache Directory Project

Constructor Summary
DefaultSchemaLdifExtractor(File outputDirectory)
          Creates an extractor which deposits files into the specified output directory.
 
Method Summary
 void extractOrCopy()
          Extracts the LDIF files from a Jar file or copies exploded LDIF resources without overwriting the resources if the schema has already been extracted.
 void extractOrCopy(boolean overwrite)
          Extracts the LDIF files from a Jar file or copies exploded LDIF resources.
static URL getUniqueResource(String resourceName, String resourceDescription)
          Gets a unique resource from the class loader.
static InputStream getUniqueResourceAsStream(String resourceName, String resourceDescription)
          Gets the unique schema file resource from the class loader off the base path.
 boolean isExtracted()
          Gets whether or not schema folder has been created or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSchemaLdifExtractor

public DefaultSchemaLdifExtractor(File outputDirectory)
Creates an extractor which deposits files into the specified output directory.

Parameters:
outputDirectory - the directory where the schema root is extracted
Method Detail

isExtracted

public boolean isExtracted()
Gets whether or not schema folder has been created or not.

Specified by:
isExtracted in interface SchemaLdifExtractor
Returns:
true if schema folder has already been extracted.

extractOrCopy

public void extractOrCopy(boolean overwrite)
                   throws IOException
Extracts the LDIF files from a Jar file or copies exploded LDIF resources.

Specified by:
extractOrCopy in interface SchemaLdifExtractor
Parameters:
overwrite - over write extracted structure if true, false otherwise
Throws:
IOException - if schema already extracted and on IO errors

extractOrCopy

public void extractOrCopy()
                   throws IOException
Extracts the LDIF files from a Jar file or copies exploded LDIF resources without overwriting the resources if the schema has already been extracted.

Specified by:
extractOrCopy in interface SchemaLdifExtractor
Throws:
IOException - if schema already extracted and on IO errors

getUniqueResourceAsStream

public static InputStream getUniqueResourceAsStream(String resourceName,
                                                    String resourceDescription)
                                             throws IOException
Gets the unique schema file resource from the class loader off the base path. If the same resource exists multiple times then an error will result since the resource is not unique.

Parameters:
resourceName - the file name of the resource to load
resourceDescription - human description of the resource
Returns:
the InputStream to read the contents of the resource
Throws:
IOException - if there are problems reading or finding a unique copy of the resource

getUniqueResource

public static URL getUniqueResource(String resourceName,
                                    String resourceDescription)
                             throws IOException
Gets a unique resource from the class loader.

Parameters:
resourceName - the name of the resource
resourceDescription - the description of the resource
Returns:
the URL to the resource in the class loader
Throws:
IOException - if there is an IO error


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.