20 package net.sf.gridarta.preferences;
22 import java.util.Arrays;
23 import java.util.prefs.AbstractPreferences;
24 import java.util.prefs.BackingStoreException;
25 import java.util.prefs.Preferences;
26 import org.apache.log4j.Category;
27 import org.apache.log4j.Logger;
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
76 final StringBuilder sb =
new StringBuilder(name);
77 for (Preferences p = parent; p !=
null; p = p.parent()) {
78 sb.insert(0,
'_').insert(0, p.name());
98 if (
LOG.isDebugEnabled()) {
99 LOG.debug(
"childrenNamesSpi(" +
fullName +
")=" + Arrays.toString(result));
105 protected AbstractPreferences
childSpi(@NotNull
final String name) {
111 throw new InternalError();
118 public void flush() throws BackingStoreException {
119 if (
LOG.isDebugEnabled()) {
131 public String
get(@NotNull
final String key, @Nullable
final String def) {
134 throw new IllegalArgumentException(
"null key");
138 synchronized (lock) {
140 if (
LOG.isDebugEnabled()) {
141 LOG.debug(
"get(" +
fullName +
", " + key +
") called for removed node");
144 throw new IllegalStateException(
"removed node");
150 }
catch (
final Exception ignored) {
162 if (
LOG.isDebugEnabled()) {
163 LOG.debug(
"get(" +
fullName +
", " + key +
", " + def +
")=" + value);
169 public boolean getBoolean(@NotNull
final String key,
final boolean def) {
170 final boolean result = super.getBoolean(key, def);
171 putSpi(key, Boolean.toString(result));
176 public double getDouble(@NotNull
final String key,
final double def) {
177 final double result = super.getDouble(key, def);
178 putSpi(key, Double.toString(result));
183 public float getFloat(@NotNull
final String key,
final float def) {
184 final float result = super.getFloat(key, def);
185 putSpi(key, Float.toString(result));
190 public int getInt(@NotNull
final String key,
final int def) {
191 final int result = super.getInt(key, def);
192 putSpi(key, Integer.toString(result));
197 public long getLong(@NotNull
final String key,
final long def) {
198 final long result = super.getLong(key, def);
199 putSpi(key, Long.toString(result));
205 protected String
getSpi(@NotNull
final String key) {
206 if (
LOG.isDebugEnabled()) {
207 LOG.debug(
"getSpi(" +
fullName +
", key=" + key +
")");
216 if (
LOG.isDebugEnabled()) {
224 protected void putSpi(@NotNull
final String key, @NotNull
final String value) {
225 if (
LOG.isDebugEnabled()) {
226 LOG.debug(
"putSpi(" +
fullName +
", key=" + key +
", value=" + value +
")");
234 if (
LOG.isDebugEnabled()) {
243 if (
LOG.isDebugEnabled()) {
244 LOG.debug(
"removeSpi(" +
fullName +
", key=" + key +
")");
252 throw new InternalError();
259 public void sync() throws BackingStoreException {
260 if (
LOG.isDebugEnabled()) {