Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
418798b1
Unverified
Commit
418798b1
authored
9 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Added BdfList/Dictionary getters for optional values.
parent
08099714
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
briar-api/src/org/briarproject/api/data/BdfDictionary.java
+55
-0
55 additions, 0 deletions
briar-api/src/org/briarproject/api/data/BdfDictionary.java
briar-api/src/org/briarproject/api/data/BdfList.java
+57
-0
57 additions, 0 deletions
briar-api/src/org/briarproject/api/data/BdfList.java
with
112 additions
and
0 deletions
briar-api/src/org/briarproject/api/data/BdfDictionary.java
+
55
−
0
View file @
418798b1
...
...
@@ -40,6 +40,13 @@ public class BdfDictionary extends Hashtable<String, Object> {
throw
new
FormatException
();
}
public
Boolean
getOptionalBoolean
(
String
key
)
throws
FormatException
{
Object
o
=
get
(
key
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
Boolean
)
return
(
Boolean
)
o
;
throw
new
FormatException
();
}
public
Boolean
getBoolean
(
String
key
,
Boolean
defaultValue
)
{
Object
o
=
get
(
key
);
if
(
o
instanceof
Boolean
)
return
(
Boolean
)
o
;
...
...
@@ -55,6 +62,16 @@ public class BdfDictionary extends Hashtable<String, Object> {
throw
new
FormatException
();
}
public
Long
getOptionalLong
(
String
key
)
throws
FormatException
{
Object
o
=
get
(
key
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
Long
)
return
(
Long
)
o
;
if
(
o
instanceof
Integer
)
return
((
Integer
)
o
).
longValue
();
if
(
o
instanceof
Short
)
return
((
Short
)
o
).
longValue
();
if
(
o
instanceof
Byte
)
return
((
Byte
)
o
).
longValue
();
throw
new
FormatException
();
}
public
Long
getLong
(
String
key
,
Long
defaultValue
)
{
Object
o
=
get
(
key
);
if
(
o
instanceof
Long
)
return
(
Long
)
o
;
...
...
@@ -71,6 +88,14 @@ public class BdfDictionary extends Hashtable<String, Object> {
throw
new
FormatException
();
}
public
Double
getOptionalDouble
(
String
key
)
throws
FormatException
{
Object
o
=
get
(
key
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
Double
)
return
(
Double
)
o
;
if
(
o
instanceof
Float
)
return
((
Float
)
o
).
doubleValue
();
throw
new
FormatException
();
}
public
Double
getDouble
(
String
key
,
Double
defaultValue
)
{
Object
o
=
get
(
key
);
if
(
o
instanceof
Double
)
return
(
Double
)
o
;
...
...
@@ -84,6 +109,13 @@ public class BdfDictionary extends Hashtable<String, Object> {
throw
new
FormatException
();
}
public
String
getOptionalString
(
String
key
)
throws
FormatException
{
Object
o
=
get
(
key
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
String
)
return
(
String
)
o
;
throw
new
FormatException
();
}
public
String
getString
(
String
key
,
String
defaultValue
)
{
Object
o
=
get
(
key
);
if
(
o
instanceof
String
)
return
(
String
)
o
;
...
...
@@ -97,6 +129,14 @@ public class BdfDictionary extends Hashtable<String, Object> {
throw
new
FormatException
();
}
public
byte
[]
getOptionalRaw
(
String
key
)
throws
FormatException
{
Object
o
=
get
(
key
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
byte
[])
return
(
byte
[])
o
;
if
(
o
instanceof
Bytes
)
return
((
Bytes
)
o
).
getBytes
();
throw
new
FormatException
();
}
public
byte
[]
getRaw
(
String
key
,
byte
[]
defaultValue
)
{
Object
o
=
get
(
key
);
if
(
o
instanceof
byte
[])
return
(
byte
[])
o
;
...
...
@@ -110,6 +150,13 @@ public class BdfDictionary extends Hashtable<String, Object> {
throw
new
FormatException
();
}
public
BdfList
getOptionalList
(
String
key
)
throws
FormatException
{
Object
o
=
get
(
key
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
BdfList
)
return
(
BdfList
)
o
;
throw
new
FormatException
();
}
public
BdfList
getList
(
String
key
,
BdfList
defaultValue
)
{
Object
o
=
get
(
key
);
if
(
o
instanceof
BdfList
)
return
(
BdfList
)
o
;
...
...
@@ -122,6 +169,14 @@ public class BdfDictionary extends Hashtable<String, Object> {
throw
new
FormatException
();
}
public
BdfDictionary
getOptionalDictionary
(
String
key
)
throws
FormatException
{
Object
o
=
get
(
key
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
BdfDictionary
)
return
(
BdfDictionary
)
o
;
throw
new
FormatException
();
}
public
BdfDictionary
getDictionary
(
String
key
,
BdfDictionary
defaultValue
)
{
Object
o
=
get
(
key
);
if
(
o
instanceof
BdfDictionary
)
return
(
BdfDictionary
)
o
;
...
...
This diff is collapsed.
Click to expand it.
briar-api/src/org/briarproject/api/data/BdfList.java
+
57
−
0
View file @
418798b1
...
...
@@ -7,6 +7,8 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.Vector
;
import
static
org
.
briarproject
.
api
.
data
.
BdfDictionary
.
NULL_VALUE
;
public
class
BdfList
extends
Vector
<
Object
>
{
/**
...
...
@@ -33,6 +35,13 @@ public class BdfList extends Vector<Object> {
throw
new
FormatException
();
}
public
Boolean
getOptionalBoolean
(
int
index
)
throws
FormatException
{
Object
o
=
get
(
index
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
Boolean
)
return
(
Boolean
)
o
;
throw
new
FormatException
();
}
public
Boolean
getBoolean
(
int
index
,
Boolean
defaultValue
)
{
Object
o
=
get
(
index
);
if
(
o
instanceof
Boolean
)
return
(
Boolean
)
o
;
...
...
@@ -48,6 +57,16 @@ public class BdfList extends Vector<Object> {
throw
new
FormatException
();
}
public
Long
getOptionalLong
(
int
index
)
throws
FormatException
{
Object
o
=
get
(
index
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
Long
)
return
(
Long
)
o
;
if
(
o
instanceof
Integer
)
return
((
Integer
)
o
).
longValue
();
if
(
o
instanceof
Short
)
return
((
Short
)
o
).
longValue
();
if
(
o
instanceof
Byte
)
return
((
Byte
)
o
).
longValue
();
throw
new
FormatException
();
}
public
Long
getLong
(
int
index
,
Long
defaultValue
)
{
Object
o
=
get
(
index
);
if
(
o
instanceof
Long
)
return
(
Long
)
o
;
...
...
@@ -64,6 +83,14 @@ public class BdfList extends Vector<Object> {
throw
new
FormatException
();
}
public
Double
getOptionalDouble
(
int
index
)
throws
FormatException
{
Object
o
=
get
(
index
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
Double
)
return
(
Double
)
o
;
if
(
o
instanceof
Float
)
return
((
Float
)
o
).
doubleValue
();
throw
new
FormatException
();
}
public
Double
getDouble
(
int
index
,
Double
defaultValue
)
{
Object
o
=
get
(
index
);
if
(
o
instanceof
Double
)
return
(
Double
)
o
;
...
...
@@ -77,6 +104,13 @@ public class BdfList extends Vector<Object> {
throw
new
FormatException
();
}
public
String
getOptionalString
(
int
index
)
throws
FormatException
{
Object
o
=
get
(
index
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
String
)
return
(
String
)
o
;
throw
new
FormatException
();
}
public
String
getString
(
int
index
,
String
defaultValue
)
{
Object
o
=
get
(
index
);
if
(
o
instanceof
String
)
return
(
String
)
o
;
...
...
@@ -90,6 +124,14 @@ public class BdfList extends Vector<Object> {
throw
new
FormatException
();
}
public
byte
[]
getOptionalRaw
(
int
index
)
throws
FormatException
{
Object
o
=
get
(
index
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
byte
[])
return
(
byte
[])
o
;
if
(
o
instanceof
Bytes
)
return
((
Bytes
)
o
).
getBytes
();
throw
new
FormatException
();
}
public
byte
[]
getRaw
(
int
index
,
byte
[]
defaultValue
)
{
Object
o
=
get
(
index
);
if
(
o
instanceof
byte
[])
return
(
byte
[])
o
;
...
...
@@ -103,6 +145,13 @@ public class BdfList extends Vector<Object> {
throw
new
FormatException
();
}
public
BdfList
getOptionalList
(
int
index
)
throws
FormatException
{
Object
o
=
get
(
index
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
BdfList
)
return
(
BdfList
)
o
;
throw
new
FormatException
();
}
public
BdfList
getList
(
int
index
,
BdfList
defaultValue
)
{
Object
o
=
get
(
index
);
if
(
o
instanceof
BdfList
)
return
(
BdfList
)
o
;
...
...
@@ -115,6 +164,14 @@ public class BdfList extends Vector<Object> {
throw
new
FormatException
();
}
public
BdfDictionary
getOptionalDictionary
(
int
index
)
throws
FormatException
{
Object
o
=
get
(
index
);
if
(
o
==
null
||
o
==
NULL_VALUE
)
return
null
;
if
(
o
instanceof
BdfDictionary
)
return
(
BdfDictionary
)
o
;
throw
new
FormatException
();
}
public
BdfDictionary
getDictionary
(
int
index
,
BdfDictionary
defaultValue
)
{
Object
o
=
get
(
index
);
if
(
o
instanceof
BdfDictionary
)
return
(
BdfDictionary
)
o
;
...
...
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