1
2
3 package it.imolinfo.jbi4corba.utils;
4
5
6 import java.io.Serializable;
7 import java.util.Properties;
8 import java.util.Vector;
9
10
11
12
13
14
15
16 public class DescInfo implements Serializable{
17
18
19 public static final int GORB=0;
20 public static final int SORB=1;
21 public static final int CORB=2;
22
23
24
25 private String localizationType="";
26
27
28
29
30 private String address="";
31 private int ORBType=GORB;
32 private boolean isValid=false;
33 private boolean isPersistent=false;
34
35 public boolean isValid() {
36 return isValid;
37 }
38
39 private Vector<Object[]> properties;
40
41
42 public int getORBType() {
43 return ORBType;
44 }
45
46 public void setORBType(int ORBType) {
47 this.ORBType = ORBType;
48 }
49
50 public String getAddress() {
51 return address;
52 }
53
54 public void setAddress(String address) {
55 this.address = address;
56 isValid=propertiesAreValid();
57 }
58
59
60
61
62 public String getLocalizationType() {
63 return localizationType;
64 }
65
66
67
68
69
70
71 public void setLocalizationType(String localizationType) {
72 this.localizationType = localizationType;
73 isValid=propertiesAreValid();
74 }
75
76
77
78
79 public Vector<Object[]> getDataSource() {
80 return properties;
81 }
82
83
84
85
86 public Properties getProperties(){
87 Properties p=new Properties();
88 for(int i=0;i<properties.size();i++){
89 p.setProperty(properties.get(i)[0].toString(),properties.get(i)[1].toString());
90 }
91 return p;
92 }
93
94
95
96
97 public void setProperties(Vector<Object[]> properties) {
98 this.properties = properties;
99 isValid=propertiesAreValid();
100 }
101
102
103
104
105 public boolean isStateless(){
106 if(localizationType.equals("")){
107 return false;
108 }
109 return true;
110
111 }
112
113 public boolean isPersistent(){
114 return isPersistent;
115 }
116
117 public void setPersistent(boolean flag){
118 isPersistent=flag;
119 }
120
121
122
123
124
125
126
127 private boolean propertiesAreValid() {
128
129 if(properties!=null){
130 for(int i=0;i<properties.size();i++){
131 String name = properties.get(i)[0].toString();
132 String value = properties.get(i)[1].toString();
133
134 if (isBlank( name) && !isBlank( value)) {
135 return false;
136 }
137 return true;
138 }
139 }
140 return false;
141
142 }
143
144
145
146
147
148
149
150
151
152
153 private static boolean isBlank(final String s) {
154 return (s == null) || (s.trim().length() == 0);
155 }
156
157
158 }