本文整理汇总了Java中java.util.prefs.NodeChangeEvent类的典型用法代码示例。如果您正苦于以下问题:Java NodeChangeEvent类的具体用法?Java NodeChangeEvent怎么用?Java NodeChangeEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeChangeEvent类属于java.util.prefs包,在下文中一共展示了NodeChangeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fireNodeEvents
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
private void fireNodeEvents(List<EventBag<NodeChangeListener, NodeChangeEvent>> events) {
if (noEvents) {
return;
}
for(EventBag<NodeChangeListener, NodeChangeEvent> bag : events) {
for(NodeChangeEvent event : bag.getEvents()) {
for(NodeChangeListener l : bag.getListeners()) {
try {
if ((event instanceof NodeChangeEventExt) && ((NodeChangeEventExt) event).isRemovalEvent()) {
l.childRemoved(event);
} else {
l.childAdded(event);
}
} catch (Throwable t) {
LOG.log(Level.WARNING, null, t);
}
}
}
}
}
示例2: testNodeAdded
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
protected ScheduledFuture<?> testNodeAdded(final NodeChangeListener listener,
final Preferences parent, final String childName, final int count) {
final ArgumentCaptor<NodeChangeEvent> captor = ArgumentCaptor.forClass(NodeChangeEvent.class);
final Runnable task = new Runnable() {
@Override public void run() {
verify(listener, times(count)).childAdded(captor.capture());
final NodeChangeEvent event = captor.getValue();
assertEquals(event.getParent(), parent);
assertEquals(event.getChild().name(), childName);
}
};
return schedule(task);
}
示例3: testNodeRemoved
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
protected ScheduledFuture<?> testNodeRemoved(final NodeChangeListener listener,
final Preferences parent, final String childName, final int count) {
final ArgumentCaptor<NodeChangeEvent> captor = ArgumentCaptor.forClass(NodeChangeEvent.class);
final Runnable task = new Runnable() {
@Override public void run() {
verify(listener, times(count)).childRemoved(captor.capture());
final NodeChangeEvent event = captor.getValue();
assertEquals(event.getParent(), parent);
assertEquals(event.getChild().name(), childName);
}
};
return schedule(task);
}
示例4: testSerialization
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Verifies serialization",
method = "!Serialization",
args = {}
)
public void testSerialization() throws Exception {
event = new NodeChangeEvent(Preferences.systemRoot(), null);
try {
SerializationTest.copySerializable(event);
fail("No expected NotSerializableException");
} catch (NotSerializableException e) {
}
}
示例5: sync
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
@Override
public void sync() throws BackingStoreException {
ArrayList<EventBag<PreferenceChangeListener, PreferenceChangeEvent>> prefEvents = new ArrayList<EventBag<PreferenceChangeListener, PreferenceChangeEvent>>();
ArrayList<EventBag<NodeChangeListener, NodeChangeEvent>> nodeEvents = new ArrayList<EventBag<NodeChangeListener, NodeChangeEvent>>();
synchronized (tree.treeLock()) {
_sync(prefEvents, nodeEvents);
}
fireNodeEvents(nodeEvents);
firePrefEvents(prefEvents);
}
示例6: testConstructor
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "NodeChangeEvent",
args = {java.util.prefs.Preferences.class, java.util.prefs.Preferences.class}
)
public void testConstructor() {
event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
.userRoot());
assertSame(Preferences.systemRoot(), event.getParent());
assertSame(Preferences.userRoot(), event.getChild());
assertSame(Preferences.systemRoot(), event.getSource());
}
示例7: testChildAdded
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Testing Interface",
method = "childAdded",
args = {java.util.prefs.NodeChangeEvent.class}
)
public void testChildAdded() {
l.childAdded(new NodeChangeEvent(Preferences.userRoot(), Preferences
.userRoot()));
}
示例8: testChildRemoved
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "Testing Interface",
method = "childRemoved",
args = {java.util.prefs.NodeChangeEvent.class}
)
public void testChildRemoved() {
l.childRemoved(new NodeChangeEvent(Preferences.userRoot(), Preferences
.userRoot()));
}
示例9: childAdded
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
public void childAdded(NodeChangeEvent e) {
synchronized (addLock) {
switch (testNum) {
case TEST_GET_CHILD:
Preferences child = e.getChild();
if (child == null) {
addResult = false;
} else {
if (child.name() == "mock1") {
addResult = true;
}
}
break;
case TEST_GET_PARENT:
Preferences parent = e.getParent();
if (parent == null) {
addResult = false;
} else {
if (parent.name() == "mock") {
addResult = true;
}
}
break;
}
++added;
addLock.notifyAll();
}
}
示例10: childRemoved
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
public void childRemoved(NodeChangeEvent e) {
synchronized (removeLock) {
switch (testNum) {
case TEST_GET_CHILD:
Preferences child = e.getChild();
if (child == null) {
removeResult = false;
} else {
if (child.name() == "mock1") {
removeResult = true;
}
}
break;
case TEST_GET_PARENT:
Preferences parent = e.getParent();
if (parent == null) {
addResult = false;
} else {
if (parent.name() == "mock") {
addResult = true;
}
}
break;
}
removed++;
removeLock.notifyAll();
}
}
示例11: testConstructor
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
public void testConstructor() {
event = new NodeChangeEvent(Preferences.systemRoot(), Preferences
.userRoot());
assertSame(Preferences.systemRoot(), event.getParent());
assertSame(Preferences.userRoot(), event.getChild());
assertSame(Preferences.systemRoot(), event.getSource());
}
示例12: testSerialization
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
public void testSerialization() throws Exception {
event = new NodeChangeEvent(Preferences.systemRoot(), null);
try {
SerializationTest.copySerializable(event);
fail("No expected NotSerializableException");
} catch (NotSerializableException e) {
}
}
示例13: childAdded
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
public void childAdded(NodeChangeEvent e) {
synchronized (addLock) {
++added;
addDispatched = true;
addLock.notifyAll();
}
}
示例14: childRemoved
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
public void childRemoved(NodeChangeEvent e) {
synchronized (removeLock) {
removed++;
removeDispatched = true;
removeLock.notifyAll();
}
}
示例15: childAdded
import java.util.prefs.NodeChangeEvent; //导入依赖的package包/类
public void childAdded(NodeChangeEvent e) {
synchronized (addLock) {
++added;
addDispatched = true;
addLock.notifyAll();
}
}