20 package net.sf.gridarta.gui.mapmenu;
23 import java.io.IOException;
24 import java.util.prefs.Preferences;
27 import org.apache.log4j.Category;
28 import org.apache.log4j.Logger;
29 import org.jetbrains.annotations.NotNull;
71 private final String
key;
85 if (
LOG.isDebugEnabled()) {
87 LOG.debug(System.identityHashCode(
this) +
" new " +
key);
99 if (
LOG.isDebugEnabled()) {
100 LOG.debug(System.identityHashCode(
this) +
" loadNumEntries=" + result);
110 if (
LOG.isDebugEnabled()) {
111 LOG.debug(System.identityHashCode(
this) +
" saveNumEntries(" + num +
")");
124 final String suffix =
"[" + index +
"]";
126 final String filename =
preferences.get(
key +
"Filename" + suffix,
"");
131 type =
Type.valueOf(typeString);
132 }
catch (
final IllegalArgumentException ex) {
133 if (
LOG.isDebugEnabled()) {
134 LOG.debug(System.identityHashCode(
this) +
" loadEntry(" + index +
")=invalid type: " + typeString +
" [" + ex.getMessage() +
"]");
136 throw new IOException(
"invalid type: " + typeString, ex);
143 }
catch (
final IllegalArgumentException ex) {
144 if (
LOG.isDebugEnabled()) {
145 LOG.debug(System.identityHashCode(
this) +
" loadEntry(" + index +
")=invalid directory name: " + title +
" [" + ex.getMessage() +
"]");
147 throw new IOException(
"invalid directory name: " + title, ex);
150 if (
LOG.isDebugEnabled()) {
151 LOG.debug(System.identityHashCode(
this) +
" loadEntry(" + index +
")=DIR[" + resultDir +
"]");
156 if (filename.isEmpty()) {
157 if (
LOG.isDebugEnabled()) {
158 LOG.debug(System.identityHashCode(
this) +
" loadEntry(" + index +
")=empty filename: " + title);
160 throw new IOException(
"bookmark without file name: " + title);
165 if (
LOG.isDebugEnabled()) {
166 LOG.debug(System.identityHashCode(
this) +
" loadEntry(" + index +
")=MAP[" + resultMap +
"]");
171 if (
LOG.isDebugEnabled()) {
172 LOG.debug(System.identityHashCode(
this) +
" loadEntry(" + index +
")=invalid type: " + type);
174 throw new IOException(
"invalid type: " + type);
186 public void saveEntry(
final int index, @NotNull
final String title, @NotNull
final String filename, @NotNull
final String
directory, @NotNull
final Type type) {
187 if (
LOG.isDebugEnabled()) {
188 LOG.debug(System.identityHashCode(
this) +
" saveEntry(title=" + title +
", filename=" + filename +
", directory=" +
directory +
", type=" + type +
")");
190 final String suffix =
"[" + index +
"]";
210 if (
LOG.isDebugEnabled()) {
211 LOG.debug(System.identityHashCode(
this) +
" removeEntry(" + index +
")");
213 final String suffix =
"[" + index +
"]";