
net.customware.license.support.util.AbstractLicensePreferences Maven / Gradle / Ivy
The newest version!
package net.customware.license.support.util;
import java.util.prefs.AbstractPreferences;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
/**
* This is an incomplete implementation of the Preferences API, with only enough
* completed to allow license key storage. This is useful if you wish to store
* the license key somewhere, but don't want to implement the full Preferences
* API.
*
* @author David Peterson
*/
public abstract class AbstractLicensePreferences extends AbstractPreferences {
protected AbstractLicensePreferences() {
super( null, "" );
}
protected AbstractLicensePreferences( AbstractLicensePreferences parent, String name ) {
super( parent, name );
}
public Preferences nodeForPackage( Class> clazz ) {
StringBuffer path = new StringBuffer( "/" );
String classname = clazz.getName();
int lastDot = classname.lastIndexOf( '.' );
if ( lastDot == -1 )
path.append( "" );
else
path.append( classname.substring( 0, lastDot ).replaceAll( "\\.", "/" ) );
return node( path.toString() );
}
/**
* @return null
.
*/
@Override protected String[] childrenNamesSpi() throws BackingStoreException {
return null;
}
/**
* Does nothing.
*/
@Override protected void flushSpi() throws BackingStoreException {
// Does nothing.
}
/**
* @return null
.
*/
@Override protected String[] keysSpi() throws BackingStoreException {
return null;
}
/**
* Does nothing.
*/
@Override protected void removeNodeSpi() throws BackingStoreException {
// Do nothing
}
/**
* Does nothing.
*/
@Override protected void syncSpi() throws BackingStoreException {
// Do nothing
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy