001 package net.minecraft.src;
002
003 import java.io.DataInput;
004 import java.io.DataOutput;
005 import java.io.IOException;
006
007 public class NBTTagString extends NBTBase
008 {
009 /** The string value for the tag (cannot be empty). */
010 public String data;
011
012 public NBTTagString(String par1Str)
013 {
014 super(par1Str);
015 }
016
017 public NBTTagString(String par1Str, String par2Str)
018 {
019 super(par1Str);
020 this.data = par2Str;
021
022 if (par2Str == null)
023 {
024 throw new IllegalArgumentException("Empty string not allowed");
025 }
026 }
027
028 /**
029 * Write the actual data contents of the tag, implemented in NBT extension classes
030 */
031 void write(DataOutput par1DataOutput) throws IOException
032 {
033 par1DataOutput.writeUTF(this.data);
034 }
035
036 /**
037 * Read the actual data contents of the tag, implemented in NBT extension classes
038 */
039 void load(DataInput par1DataInput) throws IOException
040 {
041 this.data = par1DataInput.readUTF();
042 }
043
044 /**
045 * Gets the type byte for the tag.
046 */
047 public byte getId()
048 {
049 return (byte)8;
050 }
051
052 public String toString()
053 {
054 return "" + this.data;
055 }
056
057 /**
058 * Creates a clone of the tag.
059 */
060 public NBTBase copy()
061 {
062 return new NBTTagString(this.getName(), this.data);
063 }
064
065 public boolean equals(Object par1Obj)
066 {
067 if (!super.equals(par1Obj))
068 {
069 return false;
070 }
071 else
072 {
073 NBTTagString var2 = (NBTTagString)par1Obj;
074 return this.data == null && var2.data == null || this.data != null && this.data.equals(var2.data);
075 }
076 }
077
078 public int hashCode()
079 {
080 return super.hashCode() ^ this.data.hashCode();
081 }
082 }