KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rero > client > data > DataStructureBridge


1 package rero.client.data;
2
3 import sleep.interfaces.*;
4 import sleep.engine.*;
5 import sleep.runtime.*;
6
7 import rero.client.*;
8 import rero.util.*;
9
10 import java.util.*;
11
12 import rero.ircfw.*;
13 import rero.ircfw.data.*;
14 import rero.net.*;
15 import rero.script.*;
16
17 import rero.client.notify.*;
18
19 public class DataStructureBridge extends Feature implements Variable
20 {
21    protected InternalDataList data = null;
22
23    public boolean scalarExists(String JavaDoc key)
24    {
25       if ("$time".equals(key)) { return true; }
26
27       if (data == null) { return false; }
28       if ("$me".equals(key)) { return true; }
29       if ("$lag".equals(key)) { return true; }
30       if ("$active".equals(key)) { return true; }
31 // if ("$myserver".equals(key)) { return true; }
32
// if ("$myserverport".equals(key)) { return true; }
33
if ("$mymode".equals(key)) { return true; }
34
35       return false;
36    }
37
38    public Scalar putScalar(String JavaDoc key, Scalar data) { return null; }
39    public void removeScalar(String JavaDoc key) { }
40    public Variable createLocalVariableContainer() { return null; }
41    public Variable createInternalVariableContainer() { return null; }
42
43    public Scalar getScalar(String JavaDoc key)
44    {
45       if ("$me".equals(key)) { return SleepUtils.getScalar(data.getMyNick()); }
46       if ("$time".equals(key)) { return SleepUtils.getScalar(ClientUtils.TimeStamp()); }
47       if ("$lag".equals(key) && getCapabilities().getDataStructure("lag") != null) { return SleepUtils.getScalar(((Lag)getCapabilities().getDataStructure("lag")).getLag()); }
48       if ("$active".equals(key)) { return SleepUtils.getScalar(getCapabilities().getUserInterface().getQuery()); }
49 // if ("$myserver".equals(key)) { return SleepUtils.getScalar(getCapabilities().getSocketConnection().getSocketInformation().hostname); }
50
// if ("$myserverport".equals(key)) { return SleepUtils.getScalar(getCapabilities().getSocketConnection().getSocketInformation().port); }
51
if ("$mymode".equals(key)) { return SleepUtils.getScalar(data.getMyUserInformation().getMode().toString()); }
52       return SleepUtils.getEmptyScalar();
53    }
54
55    public void init()
56    {
57       data = (InternalDataList)getCapabilities().getDataStructure("clientInformation");
58
59       GlobalVariables temp = (GlobalVariables)getCapabilities().getDataStructure("globalVariables");
60       temp.setOtherVariables(this);
61    }
62 }
63
Popular Tags