FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
epicsCoreJava/normativeTypesJava/src/org/epics/nt/NTID.java at master · shroffk/epicsCoreJava · GitHub
shroffk
epicsCoreJava
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
epicsCoreJava
/
normativeTypesJava
/
src
/
org
/
epics
/
nt
/
NTID.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
260 lines (242 loc) · 6.75 KB
Breadcrumbs
epicsCoreJava
/
normativeTypesJava
/
src
/
org
/
epics
/
nt
/
NTID.java
Copy path
File metadata and controls
260 lines (242 loc) · 6.75 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
* Copyright information and license terms for this software can be
* found in the file LICENSE that is included with the distribution
*/
package
org
.
epics
.
nt
;
/**
* Utility class for parsing an ID following the NT type ID conventions.
*
* An NT type ID will be of the from epics:nt/<type-name>:<Major>.<Minor>,
* e.g. epics:nt/NTNDArray:1.2
* @author dgh
*/
public
class
NTID
{
/**
* Creates an NTID from the specified type ID.
*
* @param id the ID to be parsed
*/
public
NTID
(
String
id
)
{
fullName
=
id
;
nsSepIndex
=
id
.
indexOf
(
'/'
);
nsQualified
=
nsSepIndex
>=
0
;
int
startIndex
=
nsQualified
?
nsSepIndex
+
1
:
0
;
versionSepIndex
=
id
.
indexOf
(
':'
,
startIndex
);
hasVersion
=
versionSepIndex
>=
0
;
}
/**
* Get the full name of the ID, that is, the original ID.
* <p>
* For example above returns "epics:nt/NTNDArray:1.2".
*
* @return the full name
*/
public
String
getFullName
() {
return
fullName
; }
/**
* Returns the fully qualified name including namespaces, but excluding version numbers
* <p>
* For example above return "epics:nt/NTNDArray".
*
* @return the fully qualified name
*/
public
String
getQualifiedName
()
{
if
(
qualifiedName
==
null
)
{
qualifiedName
=
hasVersion
?
fullName
.
substring
(
0
,
versionSepIndex
) :
fullName
;
}
return
qualifiedName
;
}
/**
* Returns the namespace
* <p>
* For example above return "epics:nt".
*
* @return the namespace
*/
public
String
getNamespace
()
{
if
(
namespace
==
null
)
{
namespace
=
nsQualified
?
fullName
.
substring
(
0
,
nsSepIndex
) :
""
;
}
return
namespace
;
}
/**
* Returns the unqualified name, without namespace or version
* <p>
* For example above return "NTNDArray".
*
* @return the unqualified name
*/
public
String
getName
()
{
if
(
name
==
null
)
{
if
(
hasVersion
)
{
name
=
fullName
.
substring
(
nsQualified
?
nsSepIndex
+
1
:
0
,
versionSepIndex
);
}
else
if
(
nsQualified
)
{
name
=
fullName
.
substring
(
nsSepIndex
+
1
);
}
else
{
name
=
fullName
;
}
}
return
name
;
}
/**
* Returns the version number as a string.
* <p>
* For example above return "1.2".
*
* @return the unqualified name
*/
public
String
getVersion
()
{
if
(
version
==
null
)
{
version
= (
hasVersion
) ?
fullName
.
substring
(
versionSepIndex
+
1
) :
""
;
}
return
version
;
}
/**
* Returns the Major version as a string.
* <p>
* For example above return "1".
*
* @return the Major string
*/
public
String
getMajorVersionString
()
{
if
(
majorVersionStr
==
null
)
{
if
(
hasVersion
)
{
endMajorIndex
=
fullName
.
indexOf
(
'.'
,
versionSepIndex
+
1
);
majorVersionStr
= (
endMajorIndex
>=
0
)
?
fullName
.
substring
(
versionSepIndex
+
1
,
endMajorIndex
) :
fullName
.
substring
(
versionSepIndex
+
1
);
}
else
majorVersionStr
=
""
;
}
return
majorVersionStr
;
}
/**
* Does the ID contain a major version and is it a number?
*
* @return true if it contains a major version number
*/
public
boolean
hasMajorVersion
()
{
if
(
hasVersion
&& !
majorVersionParsed
)
{
try
{
majorVersion
=
Integer
.
parseInt
(
getMajorVersionString
());
hasMajor
=
true
;
}
catch
(
NumberFormatException
e
) {}
majorVersionParsed
=
true
;
}
return
hasMajor
;
}
/**
* Returns the Major version as an integer.
* <p>
* For example above return 1.
* If hasMajorVersion() returns true then this method returns
* the integer version number, else it returns 0.
*
* @return the Major version
*/
public
int
getMajorVersion
()
{
// call hasMajorVersion() to calculate values
hasMajorVersion
();
return
majorVersion
;
}
/**
* Returns the Minor version as a string.
* <p>
* For example above return "2".
*
* @return the Minor string
*/
public
String
getMinorVersionString
()
{
// call hasMinorVersion() to calculate start of minor
getMajorVersionString
();
if
(
minorVersionStr
==
null
)
{
if
(
hasVersion
&&
endMajorIndex
>=
0
)
{
endMinorIndex
=
fullName
.
indexOf
(
'.'
,
endMajorIndex
+
1
);
minorVersionStr
= (
endMinorIndex
>=
0
)
?
fullName
.
substring
(
endMajorIndex
+
1
,
endMinorIndex
) :
fullName
.
substring
(
endMajorIndex
+
1
);
}
else
minorVersionStr
=
""
;
}
return
minorVersionStr
;
}
/**
* Does the ID contain a minor version and is it a number?
*
* @return true if it contains a minor version number
*/
public
boolean
hasMinorVersion
()
{
if
(
hasVersion
&& !
minorVersionParsed
)
{
try
{
minorVersion
=
Integer
.
parseInt
(
getMinorVersionString
());
hasMinor
=
true
;
}
catch
(
NumberFormatException
e
) {}
minorVersionParsed
=
true
;
}
return
hasMinor
;
}
/**
* Returns the Minor version as an integer.
* <p>
* For example above return 2.
* If hasMinorVersion() returns true then this method returns
* the integer version number, else it returns 0.
*
* @return the Minor string
*/
public
int
getMinorVersion
()
{
// call hasMinorVersion() to calculate values
hasMinorVersion
();
return
minorVersion
;
}
private
String
fullName
=
null
;
private
String
qualifiedName
=
null
;
private
String
namespace
=
null
;
private
String
name
=
null
;
private
String
version
=
null
;
private
int
nsSepIndex
= -
1
;
private
int
versionSepIndex
= -
1
;
private
boolean
nsQualified
=
false
;
private
boolean
hasVersion
=
false
;
private
int
endMajorIndex
=
0
;
private
String
majorVersionStr
=
null
;
private
boolean
majorVersionParsed
;
private
boolean
hasMajor
=
false
;
private
int
majorVersion
=
0
;
private
int
endMinorIndex
=
0
;
private
String
minorVersionStr
=
null
;
private
boolean
minorVersionParsed
;
private
boolean
hasMinor
=
false
;
private
int
minorVersion
=
0
;
}
Back
|
FazBrowse Home
|
New Git URL