Class JsonObject
java.lang.Object
de.monticore.symboltable.serialization.json.JsonObject
- All Implemented Interfaces:
JsonElement
- Direct Known Subclasses:
TraceableJsonObject
Json Objects contain members in form of name-value pairs. The name is a (unique) String, and the
value any JsonElement.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetArrayMember(String name) This method returns the value of an Array member of this object, if it exists, Otherwise, raises an error and returns null.getArrayMemberOpt(String name) This method returns an Optional of an Array member of this object, if it exists, Otherwise, returns an empty optional.As this is a Json object, return "this"booleangetBooleanMember(String name) This method returns the value of a Boolean member of this object, if it exists, Otherwise, raises an error and returns null.getBooleanMemberOpt(String name) This method returns an Optional of a Boolean member of this object, if it exists, Otherwise, returns an empty optional.doublegetDoubleMember(String name) This method returns the value of an Double member of this object, if it exists, Otherwise, raises an error and returns null.getDoubleMemberOpt(String name) This method returns an Optional of an Double member of this object, if it exists, Otherwise, returns an empty optional.floatgetFloatMember(String name) This method returns the value of an Float member of this object, if it exists, Otherwise, raises an error and returns null.getFloatMemberOpt(String name) This method returns an Optional of an Double member of this object, if it exists, Otherwise, returns an empty optional.intgetIntegerMember(String name) This method returns the value of an Integer member of this object, if it exists, Otherwise, raises an error and returns null.getIntegerMemberOpt(String name) This method returns an Optional of an Integer member of this object, if it exists, Otherwise, returns an empty optional.longgetLongMember(String name) This method returns the value of an Long member of this object, if it exists, Otherwise, raises an error and returns null.getLongMemberOpt(String name) This method returns an Optional of an Long member of this object, if it exists, Otherwise, returns an empty optional.A map with all members of this objectgetObjectMember(String name) This method returns the value of an Object member of this object, if it exists, Otherwise, raises an error and returns null.getObjectMemberOpt(String name) This method returns an Optional of an Object member of this object, if it exists, Otherwise, returns an empty optional.getStringMember(String name) This method returns the value of a String member of this object, if it exists, Otherwise, raises an error and returns null.getStringMemberOpt(String name) This method returns an Optional of a String member of this object, if it exists, Otherwise, returns an empty optional.booleanhasArrayMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Array.booleanhasBooleanMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Boolean.booleanhasDoubleMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Double.booleanhasFloatMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Float.booleanhasIntegerMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Integer.booleanhasLongMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Long.booleanbooleanbooleanhasObjectMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Object.booleanhasStringMember(String name) Checks whether there exists a member with the corresponding name and checks whether it is of type String.booleanAs this is a Json object, return trueputMember(String name, JsonElement value) removeMember(String name) voidsetMembers(Map<String, JsonElement> members) inttoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.monticore.symboltable.serialization.json.JsonElement
getAsJsonArray, getAsJsonBoolean, getAsJsonNull, getAsJsonNumber, getAsJsonString, isJsonArray, isJsonBoolean, isJsonNull, isJsonNumber, isJsonString
-
Field Details
-
members
-
-
Constructor Details
-
JsonObject
public JsonObject()
-
-
Method Details
-
isJsonObject
public boolean isJsonObject()As this is a Json object, return true- Specified by:
isJsonObjectin interfaceJsonElement- Returns:
-
getAsJsonObject
As this is a Json object, return "this"- Specified by:
getAsJsonObjectin interfaceJsonElement- Returns:
-
getMembers
A map with all members of this object- Returns:
- attributes
-
setMembers
- Parameters:
members- the attributes to set
-
sizeMembers
public int sizeMembers()- Returns:
- See Also:
-
hasMembers
public boolean hasMembers()- Returns:
- See Also:
-
hasMember
- Parameters:
name-- Returns:
- See Also:
-
getMember
- Parameters:
name-- Returns:
- See Also:
-
putMember
- Parameters:
name-value-- Returns:
- See Also:
-
removeMember
- Parameters:
name-- Returns:
- See Also:
-
getMemberNames
- Returns:
- See Also:
-
toString
-
hasStringMember
Checks whether there exists a member with the corresponding name and checks whether it is of type String.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getStringMember
This method returns the value of a String member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getStringMemberOpt
This method returns an Optional of a String member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
hasArrayMember
Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Array.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getArrayMember
This method returns the value of an Array member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getArrayMemberOpt
This method returns an Optional of an Array member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
hasBooleanMember
Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Boolean.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getBooleanMember
This method returns the value of a Boolean member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getBooleanMemberOpt
This method returns an Optional of a Boolean member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
hasObjectMember
Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Object.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getObjectMember
This method returns the value of an Object member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getObjectMemberOpt
This method returns an Optional of an Object member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
hasIntegerMember
Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Integer.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getIntegerMember
This method returns the value of an Integer member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getIntegerMemberOpt
This method returns an Optional of an Integer member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
hasDoubleMember
Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Double.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getDoubleMember
This method returns the value of an Double member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getDoubleMemberOpt
This method returns an Optional of an Double member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
hasFloatMember
Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Float.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getFloatMember
This method returns the value of an Float member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getFloatMemberOpt
This method returns an Optional of an Double member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
hasLongMember
Checks whether there exists a member with the corresponding name and checks whether it is of type JSON-Long.- Parameters:
name- The name of the possible JSON element- Returns:
- true if the correctly typed member available, false otherwise
-
getLongMember
This method returns the value of an Long member of this object, if it exists, Otherwise, raises an error and returns null.- Parameters:
name-- Returns:
-
getLongMemberOpt
This method returns an Optional of an Long member of this object, if it exists, Otherwise, returns an empty optional.- Parameters:
name-- Returns:
-
print
- Specified by:
printin interfaceJsonElement
-