Package org.btrplace.json
Class JSON
java.lang.Object
org.btrplace.json.JSON
public class JSON extends Object
Utility class to ease the serialisation and the deserialisation of the main btrplace entities.
- Author:
- Fabien Hermenier
-
Method Summary
Modifier and Type Method Description static Instance
readInstance(File f)
Read an instance from a file.static Instance
readInstance(Reader r)
Read an instance.static ReconfigurationPlan
readReconfigurationPlan(File f)
Read a reconfiguration plan from a file.static ReconfigurationPlan
readReconfigurationPlan(Reader r)
Read a plan.static String
toString(Instance instance)
Serialise a instance.static String
toString(ReconfigurationPlan plan)
Serialise a reconfiguration plan.static void
write(Instance instance, File f)
Write an instance.static void
write(Instance instance, Appendable a)
Write an instancestatic void
write(ReconfigurationPlan plan, File f)
Write a reconfiguration plan.static void
write(ReconfigurationPlan plan, Appendable a)
Write a reconfiguration plan.
-
Method Details
-
readInstance
Read an instance from a file. A file ending with '.gz' is uncompressed first- Parameters:
f
- the file to parse- Returns:
- the resulting instance
- Throws:
IllegalArgumentException
- if an error occurred while reading the file
-
readInstance
Read an instance.- Parameters:
r
- the stream to read- Returns:
- the resulting instance
- Throws:
IllegalArgumentException
- if an error occurred while reading the json
-
write
Write an instance.- Parameters:
instance
- the instance to writef
- the output file. If it ends with '.gz' it will be gzipped- Throws:
IllegalArgumentException
- if an error occurred while writing the json
-
write
Write an instance- Parameters:
instance
- the instance to writea
- the stream to write on.- Throws:
IllegalArgumentException
- if an error occurred while writing the json
-
toString
Serialise a instance.- Parameters:
instance
- the instance to write- Returns:
- the JSON string
- Throws:
IllegalArgumentException
- if an error occurred while writing the json
-
readReconfigurationPlan
Read a reconfiguration plan from a file. A file ending with '.gz' is uncompressed first- Parameters:
f
- the file to parse- Returns:
- the resulting plan
- Throws:
IllegalArgumentException
- if an error occurred while reading the file
-
readReconfigurationPlan
Read a plan.- Parameters:
r
- the stream to read- Returns:
- the resulting reconfiguration plan
- Throws:
IllegalArgumentException
- if an error occurred while reading the json
-
write
Write a reconfiguration plan.- Parameters:
plan
- the reconfiguration plan to writef
- the output file. If it ends with '.gz' it will be gzipped- Throws:
IllegalArgumentException
- if an error occurred while writing the json
-
write
Write a reconfiguration plan.- Parameters:
plan
- the plan to writea
- the stream to write on.- Throws:
IllegalArgumentException
- if an error occurred while writing the json
-
toString
Serialise a reconfiguration plan.- Parameters:
plan
- the plan to write- Returns:
- the JSON string
- Throws:
IllegalArgumentException
- if an error occurred while writing the json
-