diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2008-03-22 02:15:12 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2008-03-22 02:15:12 +0000 |
commit | a764e59e1d3a8e330f0d484fdb26b35ca3f0b2e4 (patch) | |
tree | c4ecadccdecf2809b99c0da0545f255a6ad25bb5 /src/java/com/cycling74/max/AtomString.java |
bringing pdj-0.8.3 into the main branchsvn2git-root
svn path=/trunk/externals/loaders/pdj/; revision=9621
Diffstat (limited to 'src/java/com/cycling74/max/AtomString.java')
-rw-r--r-- | src/java/com/cycling74/max/AtomString.java | 63 |
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(); + } +} |