commit a97769e934266c556305ddc6e62a6597a9e46c86 Author: Flare Microsystems Date: Thu Feb 3 20:04:49 2022 -0800 Initial commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..d171cd4 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..a3beb69 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + SDS + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/bin/com/flaremicrosystems/sds/SDSBinaryDataType.class b/bin/com/flaremicrosystems/sds/SDSBinaryDataType.class new file mode 100644 index 0000000..333eba0 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSBinaryDataType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSBooleanType.class b/bin/com/flaremicrosystems/sds/SDSBooleanType.class new file mode 100644 index 0000000..d1a18b0 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSBooleanType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSByteType.class b/bin/com/flaremicrosystems/sds/SDSByteType.class new file mode 100644 index 0000000..6a8f5cd Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSByteType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSCharType.class b/bin/com/flaremicrosystems/sds/SDSCharType.class new file mode 100644 index 0000000..4793ac4 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSCharType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSDoubleType.class b/bin/com/flaremicrosystems/sds/SDSDoubleType.class new file mode 100644 index 0000000..4f99927 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSDoubleType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSFloatType.class b/bin/com/flaremicrosystems/sds/SDSFloatType.class new file mode 100644 index 0000000..dd84fb3 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSFloatType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSIntType.class b/bin/com/flaremicrosystems/sds/SDSIntType.class new file mode 100644 index 0000000..34b7b09 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSIntType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSInvalidSizeException.class b/bin/com/flaremicrosystems/sds/SDSInvalidSizeException.class new file mode 100644 index 0000000..6bee5d1 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSInvalidSizeException.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSListType.class b/bin/com/flaremicrosystems/sds/SDSListType.class new file mode 100644 index 0000000..4ee403c Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSListType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSLongType.class b/bin/com/flaremicrosystems/sds/SDSLongType.class new file mode 100644 index 0000000..44c0558 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSLongType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSNameMapType.class b/bin/com/flaremicrosystems/sds/SDSNameMapType.class new file mode 100644 index 0000000..fea798b Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSNameMapType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSNullType.class b/bin/com/flaremicrosystems/sds/SDSNullType.class new file mode 100644 index 0000000..b45c099 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSNullType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSObject.class b/bin/com/flaremicrosystems/sds/SDSObject.class new file mode 100644 index 0000000..d66b783 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSObject.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSShortType.class b/bin/com/flaremicrosystems/sds/SDSShortType.class new file mode 100644 index 0000000..7c8377d Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSShortType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSStringType.class b/bin/com/flaremicrosystems/sds/SDSStringType.class new file mode 100644 index 0000000..da0fa96 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSStringType.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSTotalFailureException.class b/bin/com/flaremicrosystems/sds/SDSTotalFailureException.class new file mode 100644 index 0000000..b51e4c2 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSTotalFailureException.class differ diff --git a/bin/com/flaremicrosystems/sds/SDSUndefinedException.class b/bin/com/flaremicrosystems/sds/SDSUndefinedException.class new file mode 100644 index 0000000..aab38c5 Binary files /dev/null and b/bin/com/flaremicrosystems/sds/SDSUndefinedException.class differ diff --git a/src/com/flaremicrosystems/sds/SDSBinaryDataType.java b/src/com/flaremicrosystems/sds/SDSBinaryDataType.java new file mode 100644 index 0000000..5fde378 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSBinaryDataType.java @@ -0,0 +1,35 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSBinaryDataType extends SDSObject{ + + public SDSBinaryDataType() + { + } + + public SDSBinaryDataType(byte[] data) + { + this.value = data; + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeInt(value.length); + out.write(value); + } + + public SDSObject load(DataInputStream in) throws IOException, SDSUndefinedException + { + value = new byte[in.readInt()]; + return this; + } + + @Override + public int getByteLength() { + return 4 + value.length; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSBooleanType.java b/src/com/flaremicrosystems/sds/SDSBooleanType.java new file mode 100644 index 0000000..d573e93 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSBooleanType.java @@ -0,0 +1,32 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSBooleanType extends SDSObject{ + + public SDSBooleanType() { + super(); + } + public SDSBooleanType(Boolean value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeBoolean(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readBoolean(); + return this; + } + @Override + public int getByteLength() { + return 1; + } + +} diff --git a/src/com/flaremicrosystems/sds/SDSByteType.java b/src/com/flaremicrosystems/sds/SDSByteType.java new file mode 100644 index 0000000..85e9f6d --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSByteType.java @@ -0,0 +1,31 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSByteType extends SDSObject{ + + public SDSByteType() { + super(); + } + public SDSByteType(Byte value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeByte(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readByte(); + return this; + } + @Override + public int getByteLength() { + return 1; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSCharType.java b/src/com/flaremicrosystems/sds/SDSCharType.java new file mode 100644 index 0000000..5e7b928 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSCharType.java @@ -0,0 +1,31 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSCharType extends SDSObject{ + + public SDSCharType() { + super(); + } + public SDSCharType(Character value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeChar(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readChar(); + return this; + } + @Override + public int getByteLength() { + return 2; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSDoubleType.java b/src/com/flaremicrosystems/sds/SDSDoubleType.java new file mode 100644 index 0000000..87fa4d8 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSDoubleType.java @@ -0,0 +1,31 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSDoubleType extends SDSObject{ + + public SDSDoubleType() { + super(); + } + public SDSDoubleType(Double value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeDouble(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readDouble(); + return this; + } + @Override + public int getByteLength() { + return 8; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSFloatType.java b/src/com/flaremicrosystems/sds/SDSFloatType.java new file mode 100644 index 0000000..4176f95 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSFloatType.java @@ -0,0 +1,31 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSFloatType extends SDSObject{ + + public SDSFloatType() { + super(); + } + public SDSFloatType(Float value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeFloat(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readFloat(); + return this; + } + @Override + public int getByteLength() { + return 4; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSIntType.java b/src/com/flaremicrosystems/sds/SDSIntType.java new file mode 100644 index 0000000..07e5afd --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSIntType.java @@ -0,0 +1,31 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSIntType extends SDSObject{ + + public SDSIntType() { + super(); + } + public SDSIntType(Integer value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeInt(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readInt(); + return this; + } + @Override + public int getByteLength() { + return 4; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSInvalidSizeException.java b/src/com/flaremicrosystems/sds/SDSInvalidSizeException.java new file mode 100644 index 0000000..16c5f16 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSInvalidSizeException.java @@ -0,0 +1,14 @@ +package com.flaremicrosystems.sds; + +public class SDSInvalidSizeException extends RuntimeException { + + public SDSInvalidSizeException(String string) { + super(string); + } + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/src/com/flaremicrosystems/sds/SDSListType.java b/src/com/flaremicrosystems/sds/SDSListType.java new file mode 100644 index 0000000..eee804b --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSListType.java @@ -0,0 +1,71 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; + +public class SDSListType extends SDSObject>> implements Iterable { + + public SDSListType() { + this.value = new ArrayList>(); + } + + public void store(DataOutputStream out) throws IOException { + super.store(out); + out.writeInt(value.size()); + Iterator> keyIter = value.iterator(); + while (keyIter.hasNext()) { + SDSObject k = keyIter.next(); + k.store(out); + } + } + + @SuppressWarnings("unchecked") + public SDSObject load(DataInputStream in) throws IOException { + int len = in.readInt(); + for (int i = 0; i < len; i++) { + try { + SDSObject value = SDSObject.readObject(in); + this.value.add((SDSObject) value); + } catch (SDSUndefinedException e) { + e.printStackTrace(); + } + } + return this; + } + + @Override + public int getByteLength() { + int length = 4; + for (SDSObject obj : value) + length += OPCODE_BYTES + LENGTH_BYTES + obj.getByteLength(); + return length; + } + + public void add(SDSObject val) { + value.add(val); + } + + @SuppressWarnings("unchecked") + public Iterator iterator() { + return (Iterator) value.iterator(); + } + + public int size() { + return value.size(); + } + + public SDSObject get(int index) { + return value.get(index); + } + + public T[] asArray(T[] container) { + for(int i = 0; i < container.length && i < value.size(); i++) + { + container[i] = value.get(i).value; + } + return container; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSLongType.java b/src/com/flaremicrosystems/sds/SDSLongType.java new file mode 100644 index 0000000..217ae62 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSLongType.java @@ -0,0 +1,31 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSLongType extends SDSObject{ + + public SDSLongType() { + super(); + } + public SDSLongType(Long value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeLong(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readLong(); + return this; + } + @Override + public int getByteLength() { + return 8; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSNameMapType.java b/src/com/flaremicrosystems/sds/SDSNameMapType.java new file mode 100644 index 0000000..d5da03a --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSNameMapType.java @@ -0,0 +1,191 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.Iterator; +import java.util.TreeMap; + +public class SDSNameMapType extends SDSObject>>{ + public SDSNameMapType() + { + this.value = new TreeMap>(); + } + + public Boolean getBooleanValue(String key, Boolean fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSBooleanType)) + return fallback; + else return (Boolean) obj.value; + } + + public Byte getByteValue(String key, Byte fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSByteType)) + return fallback; + else return (Byte) obj.value; + } + + public Short getShortValue(String key, Short fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSShortType)) + return fallback; + else return (Short) obj.value; + } + + public Integer getIntValue(String key, Integer fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSIntType)) + return fallback; + else return (Integer) obj.value; + } + + public Character getCharacterValue(String key, Character fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSCharType)) + return fallback; + else return (Character) obj.value; + } + + public Long getLongValue(String key, Long fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSLongType)) + return fallback; + else return (Long) obj.value; + } + + public Float getFloatValue(String key, Float fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSFloatType)) + return fallback; + else return (Float) obj.value; + } + + public Double getDoubleValue(String key, Double fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSDoubleType)) + return fallback; + else return (Double) obj.value; + } + + public String getStringValue(String key, String fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSStringType)) + return fallback; + else return (String) obj.value; + } + + public SDSListType getArrayValue(String key, SDSListType fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSListType)) + return fallback; + else return (SDSListType)obj; + } + + public SDSNameMapType getNameMapping(String key, SDSNameMapType fallback) + { + SDSObject obj = this.value.get(key); + if(obj == null || !(obj instanceof SDSNameMapType)) + return fallback; + else return (SDSNameMapType)obj; + } + + public SDSObject getSDSObject(String key) + { + return this.value.get(key); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeInt(value.size()); + Iterator keyIter = value.keySet().iterator(); + while(keyIter.hasNext()) + { + String k = keyIter.next(); + SDSObject v = value.get(k); + out.writeUTF(k); + v.store(out); + } + } + + public SDSObject load(DataInputStream in) throws IOException + { + int len = in.readInt(); + for(int i = 0; i < len; i++) + { + String key = in.readUTF(); + try { + SDSObject value = SDSObject.readObject(in); + this.value.put(key, value); + } catch (SDSUndefinedException e) { + e.printStackTrace(); + } + } + return this; + } + + public void put(String name, SDSObject sdsObject) { + if(sdsObject == null) + value.remove(name); + else value.put(name, sdsObject); + } + + @Override + public int getByteLength() { + int length = 4; + Iterator keyIter = value.keySet().iterator(); + while(keyIter.hasNext()) + { + String k = keyIter.next(); + try { + length += k.getBytes("UTF-8").length; + } catch (UnsupportedEncodingException e) { + length += k.getBytes().length; + } + SDSObject v = value.get(k); + length += OPCODE_BYTES + LENGTH_BYTES + v.getByteLength(); + } + return length; + } + + public void putBoolean(String name, boolean val) { + this.put(name, new SDSBooleanType(val)); + } + public void putByte(String name, byte val) { + this.put(name, new SDSByteType(val)); + } + public void putShort(String name, short val) { + this.put(name, new SDSShortType(val)); + } + public void putChar(String name, char val) { + this.put(name, new SDSCharType(val)); + } + public void putInt(String name, int val) { + this.put(name, new SDSIntType(val)); + } + public void putLong(String name, long val) { + this.put(name, new SDSLongType(val)); + } + public void putFloat(String name, float val) { + this.put(name, new SDSFloatType(val)); + } + public void putDouble(String name, double val) { + this.put(name, new SDSDoubleType(val)); + } + + public boolean hasOfType(String name, Class tester) { + return this.value.containsKey(name) && tester.isInstance(this.value.get(name)); + } +} diff --git a/src/com/flaremicrosystems/sds/SDSNullType.java b/src/com/flaremicrosystems/sds/SDSNullType.java new file mode 100644 index 0000000..27691f1 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSNullType.java @@ -0,0 +1,13 @@ +package com.flaremicrosystems.sds; + +public class SDSNullType extends SDSObject{ + @Override + public int getByteLength() { + return 0; + } + @Override + public boolean isNull() + { + return true; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSObject.java b/src/com/flaremicrosystems/sds/SDSObject.java new file mode 100644 index 0000000..8e95cfa --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSObject.java @@ -0,0 +1,98 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +public abstract class SDSObject { + T value; + static ArrayList ids = new ArrayList(); + static ArrayList> objects = new ArrayList>(); + static ArrayList> dataTypes = new ArrayList>(); + static final int OPCODE_BYTES = 4; + static final int LENGTH_BYTES = 4; + + static { + registerDataStore(0, SDSBooleanType.class, Boolean.class); + registerDataStore(1, SDSByteType.class, Byte.class); + registerDataStore(2, SDSShortType.class, Short.class); + registerDataStore(3, SDSIntType.class, Integer.class); + registerDataStore(4, SDSCharType.class, Character.class); + registerDataStore(5, SDSLongType.class, Long.class); + registerDataStore(6, SDSFloatType.class, Float.class); + registerDataStore(7, SDSDoubleType.class, Double.class); + registerDataStore(8, SDSStringType.class, String.class); + registerDataStore(9, SDSListType.class, ArrayList.class); + registerDataStore(10, SDSNameMapType.class, HashMap.class); + registerDataStore(11, SDSBinaryDataType.class, byte[].class); + registerDataStore(12, SDSNullType.class, null); + } + + public SDSObject() { + } + + public SDSObject(T value) { + this.value = value; + } + + public T getValue() { + return value; + } + + public boolean isNull() + { + return false; + } + + public abstract int getByteLength(); + + public void setValue(T newVal) { + value = newVal; + } + + @Override + public String toString() + { + return this.value.toString(); + } + + public void store(DataOutputStream out) throws IOException { + int id = ids.get(objects.indexOf(this.getClass())); + out.writeInt(id); + int length = getByteLength(); + out.writeInt(length); + } + + public static void registerDataStore(int id, Class obj, Class dataType) { + ids.add(id); + objects.add(obj); + dataTypes.add(dataType); + } + + public SDSObject load(DataInputStream in) throws IOException, SDSUndefinedException { + return this; + } + + public static SDSObject readObject(DataInputStream in) throws IOException, SDSUndefinedException { + int id = in.readInt(); + int length = in.readInt(); + if (!ids.contains(id)) + { + in.read(new byte[length]); + throw new SDSUndefinedException("Unknown identifier: " + id); + } + @SuppressWarnings({ "rawtypes", "unchecked" }) + Class obj = (Class) objects.get(ids.get(id)); + try { + return obj.newInstance().load(in); + } catch (InstantiationException e) { + e.printStackTrace(); + throw new SDSTotalFailureException(e); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new SDSTotalFailureException(e); + } + } +} diff --git a/src/com/flaremicrosystems/sds/SDSShortType.java b/src/com/flaremicrosystems/sds/SDSShortType.java new file mode 100644 index 0000000..a339469 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSShortType.java @@ -0,0 +1,31 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class SDSShortType extends SDSObject{ + + public SDSShortType() { + super(); + } + public SDSShortType(Short value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeShort(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readShort(); + return this; + } + @Override + public int getByteLength() { + return 2; + } +} diff --git a/src/com/flaremicrosystems/sds/SDSStringType.java b/src/com/flaremicrosystems/sds/SDSStringType.java new file mode 100644 index 0000000..6a42599 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSStringType.java @@ -0,0 +1,36 @@ +package com.flaremicrosystems.sds; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; + +public class SDSStringType extends SDSObject{ + + public SDSStringType() { + super(); + } + public SDSStringType(String value) { + super(value); + } + + public void store(DataOutputStream out) throws IOException + { + super.store(out); + out.writeUTF(value); + } + + public SDSObject load(DataInputStream in) throws IOException + { + value = in.readUTF(); + return this; + } + @Override + public int getByteLength() { + try { + return value.getBytes("UTF-8").length; + } catch (UnsupportedEncodingException e) { + return value.getBytes().length; + } + } +} diff --git a/src/com/flaremicrosystems/sds/SDSTotalFailureException.java b/src/com/flaremicrosystems/sds/SDSTotalFailureException.java new file mode 100644 index 0000000..ab47e34 --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSTotalFailureException.java @@ -0,0 +1,14 @@ +package com.flaremicrosystems.sds; + +public class SDSTotalFailureException extends RuntimeException { + + public SDSTotalFailureException(Exception e) { + super(e); + } + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/src/com/flaremicrosystems/sds/SDSUndefinedException.java b/src/com/flaremicrosystems/sds/SDSUndefinedException.java new file mode 100644 index 0000000..dd3e24b --- /dev/null +++ b/src/com/flaremicrosystems/sds/SDSUndefinedException.java @@ -0,0 +1,14 @@ +package com.flaremicrosystems.sds; + +public class SDSUndefinedException extends Exception { + + public SDSUndefinedException(String string) { + super(string); + } + + /** + * + */ + private static final long serialVersionUID = 1L; + +}