aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/cycling74/max/AtomString.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/cycling74/max/AtomString.java')
-rw-r--r--src/java/com/cycling74/max/AtomString.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/java/com/cycling74/max/AtomString.java b/src/java/com/cycling74/max/AtomString.java
new file mode 100644
index 0000000..c4135af
--- /dev/null
+++ b/src/java/com/cycling74/max/AtomString.java
@@ -0,0 +1,63 @@
+package com.cycling74.max;
+
+class AtomString extends Atom {
+ private static final long serialVersionUID = 1738861344247036680L;
+ private String value;
+
+ AtomString(String value) {
+ super(DataTypes.MESSAGE);
+ this.value = value;
+ }
+
+ public int compareTo(Object obj) {
+ if ( obj instanceof AtomString ) {
+ AtomString s = (AtomString) obj;
+ return s.getString().compareTo(getString());
+ }
+ if ( obj instanceof AtomFloat ) {
+ return -1;
+ }
+ throw new ClassCastException();
+ }
+
+ public boolean isString() {
+ return true;
+ }
+
+ public Object toObject() {
+ return value;
+ }
+
+ public byte toByte() {
+ return (byte) value.charAt(0);
+ }
+
+ public char toChar() {
+ return value.charAt(0);
+ }
+
+ public String toString() {
+ return value;
+ }
+
+ public boolean toBoolean() {
+ return !value.equals("false");
+ }
+
+ public String getString() {
+ return value;
+ }
+
+ public boolean equals(Object comp) {
+ if ( !(comp instanceof AtomString) ) {
+ return false;
+ }
+ AtomString test = (AtomString) comp;
+
+ return test.value.equals(value);
+ }
+
+ public int hashCode() {
+ return value.hashCode();
+ }
+}