author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:55:09 +0200 | |
changeset 128 | 8ef997796d0a |
parent 127 | 07696c62f340 |
child 132 | 3bc4c54f4bcc |
permissions | -rw-r--r-- |
jtulach@0 | 1 |
/* |
jtulach@0 | 2 |
* Sun Public License Notice |
jtulach@0 | 3 |
* |
jtulach@0 | 4 |
* The contents of this file are subject to the Sun Public License |
jtulach@0 | 5 |
* Version 1.0 (the "License"). You may not use this file except in |
jtulach@0 | 6 |
* compliance with the License. A copy of the License is available at |
jtulach@0 | 7 |
* http://www.sun.com/ |
jtulach@0 | 8 |
* |
jtulach@0 | 9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
jtulach@36 | 10 |
* Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach. |
jtulach@36 | 11 |
* All Rights Reserved. |
jtulach@0 | 12 |
*/ |
jtulach@0 | 13 |
|
jtulach@0 | 14 |
package implpkg; |
jtulach@0 | 15 |
|
jtulach@0 | 16 |
import apipkg.Item; |
jtulach@0 | 17 |
import javax.swing.event.ChangeListener; |
jtulach@0 | 18 |
|
jtulach@0 | 19 |
/** |
jtulach@0 | 20 |
* |
jtulach@0 | 21 |
* @author Jaroslav Tulach |
jtulach@0 | 22 |
*/ |
jtulach@3 | 23 |
// BEGIN: design.less.friend.Accessor |
jtulach@0 | 24 |
public abstract class Accessor { |
jtulach@128 | 25 |
private static volatile Accessor DEFAULT; |
jtulach@128 | 26 |
public static Accessor getDefault() { |
jtulach@128 | 27 |
Accessor a = DEFAULT; |
jtulach@128 | 28 |
if (a != null) { |
jtulach@128 | 29 |
return a; |
jtulach@128 | 30 |
} |
jtulach@128 | 31 |
|
jtulach@0 | 32 |
try { |
jtulach@0 | 33 |
Class.forName(Item.class.getName(), true, Item.class.getClassLoader()); |
jtulach@0 | 34 |
} catch (Exception ex) { |
jtulach@0 | 35 |
ex.printStackTrace(); |
jtulach@0 | 36 |
} |
jtulach@128 | 37 |
|
jtulach@128 | 38 |
return DEFAULT; |
jtulach@128 | 39 |
} |
jtulach@128 | 40 |
|
jtulach@128 | 41 |
public static void setDefault(Accessor accessor) { |
jtulach@128 | 42 |
if (DEFAULT != null) { |
jtulach@128 | 43 |
throw new IllegalStateException(); |
jtulach@128 | 44 |
} |
jtulach@128 | 45 |
DEFAULT = accessor; |
jtulach@0 | 46 |
} |
jtulach@0 | 47 |
|
jtulach@0 | 48 |
public Accessor() { |
jtulach@0 | 49 |
} |
jtulach@0 | 50 |
|
jtulach@0 | 51 |
protected abstract Item newItem(); |
jtulach@0 | 52 |
protected abstract void addChangeListener(Item item, ChangeListener l); |
jtulach@0 | 53 |
} |
jtulach@3 | 54 |
// END: design.less.friend.Accessor |