1 |
/* Preferences - Preference node containing key value entries and subnodes |
/* Preferences -- Preference node containing key value entries and subnodes |
2 |
Copyright (C) 2001 Free Software Foundation, Inc. |
Copyright (C) 2001, 2004 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
307 |
* plus a '/' plus its own name. If the node is the root node and has no |
* plus a '/' plus its own name. If the node is the root node and has no |
308 |
* parent then its name is "" and its absolute path name is "/". |
* parent then its name is "" and its absolute path name is "/". |
309 |
*/ |
*/ |
310 |
abstract public String absolutePath(); |
public abstract String absolutePath(); |
311 |
|
|
312 |
/** |
/** |
313 |
* Returns true if this node comes from the user preferences tree, false |
* Returns true if this node comes from the user preferences tree, false |
314 |
* if it comes from the system preferences tree. |
* if it comes from the system preferences tree. |
315 |
*/ |
*/ |
316 |
abstract public boolean isUserNode(); |
public abstract boolean isUserNode(); |
317 |
|
|
318 |
/** |
/** |
319 |
* Returns the name of this preferences node. The name of the node cannot |
* Returns the name of this preferences node. The name of the node cannot |
320 |
* be null, can be mostly 80 characters and cannot contain any '/' |
* be null, can be mostly 80 characters and cannot contain any '/' |
321 |
* characters. The root node has as name "". |
* characters. The root node has as name "". |
322 |
*/ |
*/ |
323 |
abstract public String name(); |
public abstract String name(); |
324 |
|
|
325 |
/** |
/** |
326 |
* Returns the String given by |
* Returns the String given by |
328 |
* (isUserNode() ? "User":"System") + " Preference Node: " + absolutePath() |
* (isUserNode() ? "User":"System") + " Preference Node: " + absolutePath() |
329 |
* </code> |
* </code> |
330 |
*/ |
*/ |
331 |
abstract public String toString(); |
public abstract String toString(); |
332 |
|
|
333 |
// abstract methods (navigation) |
// abstract methods (navigation) |
334 |
|
|
340 |
* reached |
* reached |
341 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
342 |
*/ |
*/ |
343 |
abstract public String[] childrenNames() throws BackingStoreException; |
public abstract String[] childrenNames() throws BackingStoreException; |
344 |
|
|
345 |
/** |
/** |
346 |
* Returns a sub node of this preferences node if the given path is |
* Returns a sub node of this preferences node if the given path is |
353 |
* string "/" (indicating the root node) or any name on the path is more |
* string "/" (indicating the root node) or any name on the path is more |
354 |
* then 80 characters long |
* then 80 characters long |
355 |
*/ |
*/ |
356 |
abstract public Preferences node(String path); |
public abstract Preferences node(String path); |
357 |
|
|
358 |
/** |
/** |
359 |
* Returns true if the node that the path points to exists in memory or |
* Returns true if the node that the path points to exists in memory or |
371 |
* string "/" (indicating the root node) or any name on the path is more |
* string "/" (indicating the root node) or any name on the path is more |
372 |
* then 80 characters long |
* then 80 characters long |
373 |
*/ |
*/ |
374 |
abstract public boolean nodeExists(String path) |
public abstract boolean nodeExists(String path) |
375 |
throws BackingStoreException; |
throws BackingStoreException; |
376 |
|
|
377 |
/** |
/** |
380 |
* |
* |
381 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
382 |
*/ |
*/ |
383 |
abstract public Preferences parent(); |
public abstract Preferences parent(); |
384 |
|
|
385 |
// abstract methods (export) |
// abstract methods (export) |
386 |
|
|
387 |
/** |
/** |
388 |
* XXX |
* XXX |
389 |
*/ |
*/ |
390 |
abstract public void exportNode(OutputStream os) |
public abstract void exportNode(OutputStream os) |
391 |
throws BackingStoreException, |
throws BackingStoreException, |
392 |
IOException; |
IOException; |
393 |
|
|
394 |
/** |
/** |
395 |
* XXX |
* XXX |
396 |
*/ |
*/ |
397 |
abstract public void exportSubtree(OutputStream os) |
public abstract void exportSubtree(OutputStream os) |
398 |
throws BackingStoreException, |
throws BackingStoreException, |
399 |
IOException; |
IOException; |
400 |
|
|
408 |
* reached |
* reached |
409 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
410 |
*/ |
*/ |
411 |
abstract public String[] keys() throws BackingStoreException; |
public abstract String[] keys() throws BackingStoreException; |
412 |
|
|
413 |
/** |
/** |
414 |
* Returns the value associated with the key in this preferences node. If |
* Returns the value associated with the key in this preferences node. If |
420 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
421 |
* @exception NullPointerException if key is null |
* @exception NullPointerException if key is null |
422 |
*/ |
*/ |
423 |
abstract public String get(String key, String defaultVal); |
public abstract String get(String key, String defaultVal); |
424 |
|
|
425 |
/** |
/** |
426 |
* Convenience method for getting the given entry as a boolean. |
* Convenience method for getting the given entry as a boolean. |
432 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
433 |
* @exception NullPointerException if key is null |
* @exception NullPointerException if key is null |
434 |
*/ |
*/ |
435 |
abstract public boolean getBoolean(String key, boolean defaultVal); |
public abstract boolean getBoolean(String key, boolean defaultVal); |
436 |
|
|
437 |
/** |
/** |
438 |
* Convenience method for getting the given entry as a byte array. |
* Convenience method for getting the given entry as a byte array. |
445 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
446 |
* @exception NullPointerException if key is null |
* @exception NullPointerException if key is null |
447 |
*/ |
*/ |
448 |
abstract public byte[] getByteArray(String key, byte[] defaultVal); |
public abstract byte[] getByteArray(String key, byte[] defaultVal); |
449 |
|
|
450 |
/** |
/** |
451 |
* Convenience method for getting the given entry as a double. |
* Convenience method for getting the given entry as a double. |
457 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
458 |
* @exception NullPointerException if key is null |
* @exception NullPointerException if key is null |
459 |
*/ |
*/ |
460 |
abstract public double getDouble(String key, double defaultVal); |
public abstract double getDouble(String key, double defaultVal); |
461 |
|
|
462 |
/** |
/** |
463 |
* Convenience method for getting the given entry as a float. |
* Convenience method for getting the given entry as a float. |
469 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
470 |
* @exception NullPointerException if key is null |
* @exception NullPointerException if key is null |
471 |
*/ |
*/ |
472 |
abstract public float getFloat(String key, float defaultVal); |
public abstract float getFloat(String key, float defaultVal); |
473 |
|
|
474 |
/** |
/** |
475 |
* Convenience method for getting the given entry as an integer. |
* Convenience method for getting the given entry as an integer. |
481 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
482 |
* @exception NullPointerException if key is null |
* @exception NullPointerException if key is null |
483 |
*/ |
*/ |
484 |
abstract public int getInt(String key, int defaultVal); |
public abstract int getInt(String key, int defaultVal); |
485 |
|
|
486 |
/** |
/** |
487 |
* Convenience method for getting the given entry as a long. |
* Convenience method for getting the given entry as a long. |
493 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
494 |
* @exception NullPointerException if key is null |
* @exception NullPointerException if key is null |
495 |
*/ |
*/ |
496 |
abstract public long getLong(String key, long defaultVal); |
public abstract long getLong(String key, long defaultVal); |
497 |
|
|
498 |
/** |
/** |
499 |
* Sets the value of the given preferences entry for this node. |
* Sets the value of the given preferences entry for this node. |
507 |
* @exception IllegalArgumentException if either key or value are to large |
* @exception IllegalArgumentException if either key or value are to large |
508 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
509 |
*/ |
*/ |
510 |
abstract public void put(String key, String value); |
public abstract void put(String key, String value); |
511 |
|
|
512 |
/** |
/** |
513 |
* Convenience method for setting the given entry as a boolean. |
* Convenience method for setting the given entry as a boolean. |
518 |
* @exception IllegalArgumentException if the key length is to large |
* @exception IllegalArgumentException if the key length is to large |
519 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
520 |
*/ |
*/ |
521 |
abstract public void putBoolean(String key, boolean value); |
public abstract void putBoolean(String key, boolean value); |
522 |
|
|
523 |
/** |
/** |
524 |
* Convenience method for setting the given entry as an array of bytes. |
* Convenience method for setting the given entry as an array of bytes. |
533 |
* @exception IllegalArgumentException if either key or value are to large |
* @exception IllegalArgumentException if either key or value are to large |
534 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
535 |
*/ |
*/ |
536 |
abstract public void putByteArray(String key, byte[] value); |
public abstract void putByteArray(String key, byte[] value); |
537 |
|
|
538 |
/** |
/** |
539 |
* Convenience method for setting the given entry as a double. |
* Convenience method for setting the given entry as a double. |
544 |
* @exception IllegalArgumentException if the key length is to large |
* @exception IllegalArgumentException if the key length is to large |
545 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
546 |
*/ |
*/ |
547 |
abstract public void putDouble(String key, double value); |
public abstract void putDouble(String key, double value); |
548 |
|
|
549 |
/** |
/** |
550 |
* Convenience method for setting the given entry as a float. |
* Convenience method for setting the given entry as a float. |
555 |
* @exception IllegalArgumentException if the key length is to large |
* @exception IllegalArgumentException if the key length is to large |
556 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
557 |
*/ |
*/ |
558 |
abstract public void putFloat(String key, float value); |
public abstract void putFloat(String key, float value); |
559 |
|
|
560 |
/** |
/** |
561 |
* Convenience method for setting the given entry as an integer. |
* Convenience method for setting the given entry as an integer. |
566 |
* @exception IllegalArgumentException if the key length is to large |
* @exception IllegalArgumentException if the key length is to large |
567 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
568 |
*/ |
*/ |
569 |
abstract public void putInt(String key, int value); |
public abstract void putInt(String key, int value); |
570 |
|
|
571 |
/** |
/** |
572 |
* Convenience method for setting the given entry as a long. |
* Convenience method for setting the given entry as a long. |
577 |
* @exception IllegalArgumentException if the key length is to large |
* @exception IllegalArgumentException if the key length is to large |
578 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
579 |
*/ |
*/ |
580 |
abstract public void putLong(String key, long value); |
public abstract void putLong(String key, long value); |
581 |
|
|
582 |
/** |
/** |
583 |
* Removes the preferences entry from this preferences node. |
* Removes the preferences entry from this preferences node. |
589 |
* @exception IllegalArgumentException if the key length is to large |
* @exception IllegalArgumentException if the key length is to large |
590 |
* @exception IllegalStateException when this node has been removed |
* @exception IllegalStateException when this node has been removed |
591 |
*/ |
*/ |
592 |
abstract public void remove(String key); |
public abstract void remove(String key); |
593 |
|
|
594 |
// abstract methods (preference node manipulation) |
// abstract methods (preference node manipulation) |
595 |
|
|
604 |
* reached |
* reached |
605 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
606 |
*/ |
*/ |
607 |
abstract public void clear() throws BackingStoreException; |
public abstract void clear() throws BackingStoreException; |
608 |
|
|
609 |
/** |
/** |
610 |
* Writes all preference changes on this and any subnode that have not |
* Writes all preference changes on this and any subnode that have not |
618 |
* reached |
* reached |
619 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
620 |
*/ |
*/ |
621 |
abstract public void flush() throws BackingStoreException; |
public abstract void flush() throws BackingStoreException; |
622 |
|
|
623 |
/** |
/** |
624 |
* Writes and reads all preference changes to and from this and any |
* Writes and reads all preference changes to and from this and any |
630 |
* reached |
* reached |
631 |
* @exception IllegalStateException if this node has been removed |
* @exception IllegalStateException if this node has been removed |
632 |
*/ |
*/ |
633 |
abstract public void sync() throws BackingStoreException; |
public abstract void sync() throws BackingStoreException; |
634 |
|
|
635 |
/** |
/** |
636 |
* Removes this and all subnodes from the backing store and clears all |
* Removes this and all subnodes from the backing store and clears all |
651 |
* @exception IllegalStateException if this node has already been removed |
* @exception IllegalStateException if this node has already been removed |
652 |
* @exception UnsupportedOperationException if this is a root node |
* @exception UnsupportedOperationException if this is a root node |
653 |
*/ |
*/ |
654 |
abstract public void removeNode() throws BackingStoreException; |
public abstract void removeNode() throws BackingStoreException; |
655 |
|
|
656 |
// abstract methods (listeners) |
// abstract methods (listeners) |
657 |
|
|
658 |
abstract public void addNodeChangeListener(NodeChangeListener listener); |
public abstract void addNodeChangeListener(NodeChangeListener listener); |
659 |
|
|
660 |
abstract public void addPreferenceChangeListener |
public abstract void addPreferenceChangeListener |
661 |
(PreferenceChangeListener listener); |
(PreferenceChangeListener listener); |
662 |
|
|
663 |
abstract public void removeNodeChangeListener(NodeChangeListener listener); |
public abstract void removeNodeChangeListener(NodeChangeListener listener); |
664 |
|
|
665 |
abstract public void removePreferenceChangeListener |
public abstract void removePreferenceChangeListener |
666 |
(PreferenceChangeListener listener); |
(PreferenceChangeListener listener); |
|
|
|
667 |
} |
} |
668 |
|
|