Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ramin Yaghoubzadeh Torky
ipaaca
Commits
cec236b3
Commit
cec236b3
authored
13 years ago
by
hvanwelbergen
Browse files
Options
Downloads
Patches
Plain Diff
x
parent
00075398
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/ipaaca/Info.java
+21
-35
21 additions, 35 deletions
java/src/ipaaca/Info.java
with
21 additions
and
35 deletions
java/src/ipaaca/Info.java
+
21
−
35
View file @
cec236b3
...
...
@@ -35,8 +35,10 @@ import javax.swing.JOptionPane;
*/
public
final
class
Info
{
private
Info
(){}
private
Info
()
{
}
private
static
Package
pack
=
new
Info
().
getClass
().
getPackage
();
public
final
static
String
packageName
=
pack
.
getName
();
...
...
@@ -52,33 +54,27 @@ public final class Info
buf
.
append
(
"\n"
);
if
(
pack
.
getSpecificationTitle
()
!=
null
)
{
buf
.
append
(
"Specification-Title: "
+
pack
.
getSpecificationTitle
()
+
"\n"
);
buf
.
append
(
"Specification-Title: "
+
pack
.
getSpecificationTitle
()
+
"\n"
);
}
if
(
pack
.
getSpecificationVersion
()
!=
null
)
{
buf
.
append
(
"Specification-Version: "
+
pack
.
getSpecificationVersion
()
+
"\n"
);
buf
.
append
(
"Specification-Version: "
+
pack
.
getSpecificationVersion
()
+
"\n"
);
}
if
(
pack
.
getSpecificationVendor
()
!=
null
)
{
buf
.
append
(
"Specification-Vendor: "
+
pack
.
getSpecificationVendor
()
+
"\n"
);
buf
.
append
(
"Specification-Vendor: "
+
pack
.
getSpecificationVendor
()
+
"\n"
);
}
if
(
pack
.
getImplementationTitle
()
!=
null
)
{
buf
.
append
(
"Implementation-Title: "
+
pack
.
getImplementationTitle
()
+
"\n"
);
buf
.
append
(
"Implementation-Title: "
+
pack
.
getImplementationTitle
()
+
"\n"
);
}
if
(
pack
.
getImplementationVersion
()
!=
null
)
{
buf
.
append
(
"Implementation-Version: "
+
pack
.
getImplementationVersion
()
+
"\n"
);
buf
.
append
(
"Implementation-Version: "
+
pack
.
getImplementationVersion
()
+
"\n"
);
}
if
(
pack
.
getImplementationVendor
()
!=
null
)
{
buf
.
append
(
"Implementation-Vendor: "
+
pack
.
getImplementationVendor
()
+
"\n"
);
buf
.
append
(
"Implementation-Vendor: "
+
pack
.
getImplementationVendor
()
+
"\n"
);
}
return
buf
.
toString
();
}
...
...
@@ -90,15 +86,11 @@ public final class Info
*/
public
static
void
requireVersion
(
String
requiredVersion
)
{
if
(
pack
.
getSpecificationVersion
()
==
null
)
return
;
// no check possible, so assume ok
if
(
pack
.
isCompatibleWith
(
requiredVersion
))
return
;
String
msg
=
"Package "
+
packageName
+
" Version "
+
pack
.
getSpecificationVersion
()
+
" does not meet the required version "
+
requiredVersion
;
JOptionPane
.
showMessageDialog
(
null
,
msg
,
"Package Info"
,
JOptionPane
.
PLAIN_MESSAGE
);
if
(
pack
.
getSpecificationVersion
()
==
null
)
return
;
// no check possible, so assume ok
if
(
pack
.
isCompatibleWith
(
requiredVersion
))
return
;
String
msg
=
"Package "
+
packageName
+
" Version "
+
pack
.
getSpecificationVersion
()
+
" does not meet the required version "
+
requiredVersion
;
JOptionPane
.
showMessageDialog
(
null
,
msg
,
"Package Info"
,
JOptionPane
.
PLAIN_MESSAGE
);
throw
new
RuntimeException
(
msg
);
}
...
...
@@ -126,8 +118,7 @@ public final class Info
public
static
boolean
isCompatibleWith
(
String
desiredVersion
)
{
String
specificationVersion
=
pack
.
getSpecificationVersion
();
if
(
specificationVersion
==
null
)
return
true
;
// no spec version available, so assume ok
if
(
specificationVersion
==
null
)
return
true
;
// no spec version available, so assume ok
String
[]
desiredNums
=
desiredVersion
.
split
(
"[.]"
);
String
[]
specificationNums
=
specificationVersion
.
split
(
"[.]"
);
int
desired
,
specified
;
...
...
@@ -148,19 +139,15 @@ public final class Info
specified
=
0
;
}
if
(
desired
<
specified
)
return
true
;
if
(
desired
>
specified
)
return
false
;
if
(
desired
<
specified
)
return
true
;
if
(
desired
>
specified
)
return
false
;
}
return
true
;
}
catch
(
NumberFormatException
e
)
{
System
.
out
.
println
(
packageName
+
".Info.isCompatibelWith method: illegal version numbers: "
+
desiredVersion
+
" / "
+
specificationVersion
);
System
.
out
.
println
(
packageName
+
".Info.isCompatibelWith method: illegal version numbers: "
+
desiredVersion
+
" / "
+
specificationVersion
);
return
false
;
}
}
...
...
@@ -170,8 +157,7 @@ public final class Info
*/
public
static
void
main
(
String
[]
arg
)
{
JOptionPane
.
showMessageDialog
(
null
,
Info
.
manifestInfo
(),
"Package Info"
,
JOptionPane
.
PLAIN_MESSAGE
);
JOptionPane
.
showMessageDialog
(
null
,
Info
.
manifestInfo
(),
"Package Info"
,
JOptionPane
.
PLAIN_MESSAGE
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment