Adjusted ion reserved ranges.

v5stable
Ondřej Hruška 11 years ago
parent 035aa58847
commit e630320bd9
  1. 41
      src/mightypork/util/files/ion/Ion.java

@ -17,12 +17,12 @@ import mightypork.util.logging.Log;
public class Ion { public class Ion {
/* /*
* 0-29 ... primitive and Java built-in types * 0-19 ... primitive and Java built-in types
* 30-59 ... technical marks * 20-39 ... technical marks
* 60-99 ... built-in ION types * 40-99 ... built-in ION types
*/ */
// primitives // primitives 0..19
/** Null mark (for internal use) */ /** Null mark (for internal use) */
private static final short NULL = 0; private static final short NULL = 0;
/** Boolean mark (for internal use) */ /** Boolean mark (for internal use) */
@ -44,37 +44,37 @@ public class Ion {
/** String mark (for internal use) */ /** String mark (for internal use) */
private static final short STRING = 9; private static final short STRING = 9;
// technical // technical 20..39
/** /**
* Entry mark - general purpose, marks an entry in sequence of objects. Used * Entry mark - general purpose, marks an entry in sequence of objects. Used
* to indicate that the sequence continues wityh another element. * to indicate that the sequence continues wityh another element.
*/ */
public static final short ENTRY = 30; public static final short ENTRY = 20;
/** /**
* Start mark - general purpose, marks start of a sequence of stored * Start mark - general purpose, marks start of a sequence of stored
* objects. * objects.
*/ */
public static final short START = 31; public static final short START = 21;
/** /**
* End mark - general purpose, marks end of sequence of stored objects. * End mark - general purpose, marks end of sequence of stored objects.
*/ */
public static final short END = 32; public static final short END = 22;
/** /**
* Length mark, indicating length of something (such as array) - general * Length mark, indicating length of something (such as array) - general
* purpose * purpose
*/ */
public static final short LENGTH = 33; public static final short LENGTH = 23;
// built in // built in 40..99
/** Map mark (built-in data structure) */ /** Map mark (built-in data structure) */
static final short DATA_BUNDLE = 60; static final short DATA_BUNDLE = 40;
/** List mark (built-in data structure) */ /** List mark (built-in data structure) */
static final short DATA_LIST = 61; static final short DATA_LIST = 41;
/** Ionizables<Mark, Class> */ /** Ionizables<Mark, Class> */
private static Map<Short, Class<?>> customIonizables = new HashMap<>(); private static Map<Short, Class<?>> customIonizables = new HashMap<>();
@ -163,6 +163,19 @@ public class Ion {
} }
/**
* Write Ion object to a stream.
*
* @param out output stream
* @param obj written object
* @throws IOException
*/
public static void toStream(OutputStream out, Object obj) throws IOException
{
writeObject(out, obj);
}
/** /**
* Store Ion object to file. * Store Ion object to file.
* *
@ -173,10 +186,6 @@ public class Ion {
public static void toFile(File path, Object obj) throws IOException public static void toFile(File path, Object obj) throws IOException
{ {
try(OutputStream out = new FileOutputStream(path)) { try(OutputStream out = new FileOutputStream(path)) {
final String f = path.toString();
final File dir = new File(f.substring(0, f.lastIndexOf(File.separator)));
if (!dir.mkdirs()) throw new IOException("Could not create file.");
writeObject(out, obj); writeObject(out, obj);

Loading…
Cancel
Save