Refactored ch.spacebase to org.spacehq, reformatted code and line endings.

This commit is contained in:
Steveice10 2014-03-01 16:46:32 -08:00
parent d7f2398e00
commit 7f7acc4193
27 changed files with 1404 additions and 1336 deletions

10
.gitignore vendored
View File

@ -1,6 +1,12 @@
bin
.git
lib
.settings
.classpath
.project
.settings
*.iml
.idea
target

View File

@ -13,7 +13,7 @@ OpenNBT is a library for reading and writing NBT files, with some extra custom t
--------------
OpenNBT uses Maven to manage dependencies. Simply run 'mvn clean install' in the source's directory.
You can also download a build <b>[here](http://build.spacebase.ch/job/OpenNBT/)</b>.
You can also download a build <b>[here](http://build.spacehq.org/job/OpenNBT/)</b>.
<b>License</b>

19
pom.xml
View File

@ -1,8 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.spacebase</groupId>
<groupId>org.spacehq</groupId>
<artifactId>opennbt</artifactId>
<version>1.3-SNAPSHOT</version>
<version>1.3</version>
<packaging>jar</packaging>
<name>OpenNBT</name>
@ -25,14 +26,14 @@
<distributionManagement>
<repository>
<id>spacebase</id>
<name>spacebase-releases</name>
<url>http://repo.spacebase.ch/content/repositories/release/</url>
<id>spacehq</id>
<name>spacehq-releases</name>
<url>http://repo.spacehq.org/content/repositories/release/</url>
</repository>
<snapshotRepository>
<id>spacebase</id>
<name>spacebase-snapshots</name>
<url>http://repo.spacebase.ch/content/repositories/snapshots/</url>
<id>spacehq</id>
<name>spacehq-snapshots</name>
<url>http://repo.spacehq.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

View File

@ -1,26 +1,20 @@
package ch.spacebase.opennbt;
package org.spacehq.opennbt;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.spacehq.opennbt.tag.CompoundTag;
import org.spacehq.opennbt.tag.Tag;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import ch.spacebase.opennbt.tag.CompoundTag;
import ch.spacebase.opennbt.tag.Tag;
public class NBTFileIO {
/**
* Reads the root CompoundTag from the given file.
*
* @param path Path of the file.
* @return The read compound tag.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static CompoundTag readFile(String path) throws IOException {
return readFile(new File(path));
@ -28,9 +22,10 @@ public class NBTFileIO {
/**
* Reads the root CompoundTag from the given file.
*
* @param file File to read from.
* @return The read compound tag.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static CompoundTag readFile(File file) throws IOException {
return readFile(file, true);
@ -38,10 +33,11 @@ public class NBTFileIO {
/**
* Reads the root CompoundTag from the given file.
*
* @param path Path of the file.
* @param compressed Whether the NBT file is compressed.
* @return The read compound tag.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static CompoundTag readFile(String path, boolean compressed) throws IOException {
return readFile(new File(path), compressed);
@ -49,10 +45,11 @@ public class NBTFileIO {
/**
* Reads the root CompoundTag from the given file.
*
* @param file File to read from.
* @param compressed Whether the NBT file is compressed.
* @return The read compound tag.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static CompoundTag readFile(File file, boolean compressed) throws IOException {
InputStream in = new FileInputStream(file);
@ -70,9 +67,10 @@ public class NBTFileIO {
/**
* Writes the given root CompoundTag to the given file.
*
* @param tag Tag to write.
* @param path Path to write to.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static void writeFile(CompoundTag tag, String path) throws IOException {
writeFile(tag, new File(path));
@ -80,9 +78,10 @@ public class NBTFileIO {
/**
* Writes the given root CompoundTag to the given file.
*
* @param tag Tag to write.
* @param file File to write to.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static void writeFile(CompoundTag tag, File file) throws IOException {
writeFile(tag, file, true);
@ -90,10 +89,11 @@ public class NBTFileIO {
/**
* Writes the given root CompoundTag to the given file.
*
* @param tag Tag to write.
* @param path Path to write to.
* @param compressed Whether the NBT file should be compressed.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static void writeFile(CompoundTag tag, String path, boolean compressed) throws IOException {
writeFile(tag, new File(path), compressed);
@ -101,10 +101,11 @@ public class NBTFileIO {
/**
* Writes the given root CompoundTag to the given file.
*
* @param tag Tag to write.
* @param file File to write to.
* @param compressed Whether the NBT file should be compressed.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static void writeFile(CompoundTag tag, File file, boolean compressed) throws IOException {
if(!file.exists()) {

View File

@ -1,4 +1,6 @@
package ch.spacebase.opennbt;
package org.spacehq.opennbt;
import org.spacehq.opennbt.tag.Tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -9,8 +11,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import ch.spacebase.opennbt.tag.Tag;
/**
* A class containing methods for reading/writing NBT tags.
*/
@ -20,9 +20,10 @@ public class NBTIO {
/**
* Reads NBT tags until an end tag is reached.
*
* @param in Input stream to read from.
* @return The read tags.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static List<Tag> readUntilEndTag(DataInputStream in) throws IOException {
List<Tag> ret = new ArrayList<Tag>();
@ -40,9 +41,10 @@ public class NBTIO {
/**
* Reads an NBT tag.
*
* @param in Input stream to read from.
* @return The read tag, or null if the tag is an end tag.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static Tag readTag(DataInputStream in) throws IOException {
int id = in.readByte() & 0xFF;
@ -64,9 +66,10 @@ public class NBTIO {
/**
* Writes a collection of tags to an output stream.
*
* @param out Output stream to write to.
* @param tags Tags to write.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static void writeTags(DataOutputStream out, Collection<Tag> tags) throws IOException {
for(Tag tag : tags) {
@ -76,9 +79,10 @@ public class NBTIO {
/**
* Writes a tag to an output stream.
*
* @param out Output stream to write to.
* @param tag Tag to write.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public static void writeTag(DataOutputStream out, Tag tag) throws IOException {
byte[] nameBytes = tag.getName().getBytes(CHARSET);

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt;
package org.spacehq.opennbt;
/**
* An exception thrown when an error occurs while registering a tag class.

View File

@ -1,50 +1,20 @@
package ch.spacebase.opennbt;
package org.spacehq.opennbt;
import org.spacehq.opennbt.tag.*;
import org.spacehq.opennbt.tag.custom.*;
import java.util.HashMap;
import java.util.Map;
import ch.spacebase.opennbt.tag.ByteArrayTag;
import ch.spacebase.opennbt.tag.ByteTag;
import ch.spacebase.opennbt.tag.CompoundTag;
import ch.spacebase.opennbt.tag.DoubleTag;
import ch.spacebase.opennbt.tag.FloatTag;
import ch.spacebase.opennbt.tag.IntArrayTag;
import ch.spacebase.opennbt.tag.IntTag;
import ch.spacebase.opennbt.tag.ListTag;
import ch.spacebase.opennbt.tag.LongTag;
import ch.spacebase.opennbt.tag.ShortTag;
import ch.spacebase.opennbt.tag.StringTag;
import ch.spacebase.opennbt.tag.Tag;
import ch.spacebase.opennbt.tag.custom.DoubleArrayTag;
import ch.spacebase.opennbt.tag.custom.FloatArrayTag;
import ch.spacebase.opennbt.tag.custom.LongArrayTag;
import ch.spacebase.opennbt.tag.custom.SerializableArrayTag;
import ch.spacebase.opennbt.tag.custom.SerializableTag;
import ch.spacebase.opennbt.tag.custom.ShortArrayTag;
import ch.spacebase.opennbt.tag.custom.StringArrayTag;
/**
* A registry containing different tag classes.
*/
public class TagRegistry {
private static final Map<Integer, Class<? extends Tag>> tags = new HashMap<Integer, Class<? extends Tag>>();
private static boolean registered = false;
static {
try {
registerDefaultTags();
} catch(TagRegisterException e) {
throw new RuntimeException("Failed to register default tags.", e);
}
}
protected static void registerDefaultTags() throws TagRegisterException {
if(registered) {
return;
}
registered = true;
register(CompoundTag.class);
register(ListTag.class);
@ -65,10 +35,14 @@ public class TagRegistry {
register(IntArrayTag.class);
register(LongArrayTag.class);
register(ShortArrayTag.class);
} catch(TagRegisterException e) {
throw new RuntimeException("Failed to register default tags.", e);
}
}
/**
* Registers a tag class.
*
* @param tag Tag class to register.
* @throws TagRegisterException If an error occurs while registering the tag.
*/
@ -83,6 +57,7 @@ public class TagRegistry {
/**
* Gets the tag class with the given id.
*
* @param id Id of the tag.
* @return The tag class with the given id.
*/
@ -92,6 +67,7 @@ public class TagRegistry {
/**
* Gets the id of the given tag class.
*
* @param clazz The tag class to get the id for.
* @return The id of the given tag class, or -1 if it cannot be found.
*/
@ -107,6 +83,7 @@ public class TagRegistry {
/**
* Creates an instance of the tag with the given id, using the String constructor.
*
* @param id Id of the tag.
* @param tagName Name to give the tag.
* @return The created tag, or null if it could not be created or the type does not exist.

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class ByteArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public ByteArrayTag(String name) {
@ -21,6 +22,7 @@ public class ByteArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -36,6 +38,7 @@ public class ByteArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(byte[] value) {
@ -48,6 +51,7 @@ public class ByteArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -57,6 +61,7 @@ public class ByteArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -66,6 +71,7 @@ public class ByteArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class ByteTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public ByteTag(String name) {
@ -21,6 +22,7 @@ public class ByteTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -36,6 +38,7 @@ public class ByteTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(byte value) {

View File

@ -1,17 +1,13 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import org.spacehq.opennbt.NBTIO;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.Map.Entry;
import ch.spacebase.opennbt.NBTIO;
/**
* A compound tag containing other tags.
*/
@ -21,6 +17,7 @@ public class CompoundTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public CompoundTag(String name) {
@ -29,6 +26,7 @@ public class CompoundTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -44,6 +42,7 @@ public class CompoundTag extends Tag {
/**
* Gets the tag with the specified name.
*
* @param tagName Name of the tag.
* @return The tag with the specified name.
*/
@ -53,6 +52,7 @@ public class CompoundTag extends Tag {
/**
* Puts the tag into this compound tag.
*
* @param tag Tag to put into this compound tag.
* @return The previous tag associated with its name, or null if there wasn't one.
*/
@ -62,6 +62,7 @@ public class CompoundTag extends Tag {
/**
* Removes a tag from this compound tag.
*
* @param tagName Name of the tag to remove.
* @return The removed tag.
*/
@ -71,6 +72,7 @@ public class CompoundTag extends Tag {
/**
* Gets a set of keys in this compound tag.
*
* @return The compound tag's key set.
*/
public Set<String> keySet() {
@ -79,6 +81,7 @@ public class CompoundTag extends Tag {
/**
* Gets a collection of tags in this compound tag.
*
* @return This compound tag's tags.
*/
public Collection<Tag> values() {
@ -87,6 +90,7 @@ public class CompoundTag extends Tag {
/**
* Gets the number of tags in this compound tag.
*
* @return This compound tag's size.
*/
public int size() {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class DoubleTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public DoubleTag(String name) {
@ -21,6 +22,7 @@ public class DoubleTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -51,6 +53,7 @@ public class DoubleTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(double value) {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class FloatTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public FloatTag(String name) {
@ -21,6 +22,7 @@ public class FloatTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -51,6 +53,7 @@ public class FloatTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(float value) {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class IntArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public IntArrayTag(String name) {
@ -21,6 +22,7 @@ public class IntArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -57,6 +59,7 @@ public class IntArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(int[] value) {
@ -69,6 +72,7 @@ public class IntArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -78,6 +82,7 @@ public class IntArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -87,6 +92,7 @@ public class IntArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class IntTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public IntTag(String name) {
@ -21,6 +22,7 @@ public class IntTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -36,6 +38,7 @@ public class IntTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(int value) {

View File

@ -1,4 +1,6 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import org.spacehq.opennbt.TagRegistry;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -7,8 +9,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import ch.spacebase.opennbt.TagRegistry;
/**
* A tag containing a list of tags.
*/
@ -19,6 +19,7 @@ public class ListTag<T extends Tag> extends Tag implements Iterable<T> {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public ListTag(String name) {
@ -28,6 +29,7 @@ public class ListTag<T extends Tag> extends Tag implements Iterable<T> {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param type Tag type of the list.
*/
@ -37,6 +39,7 @@ public class ListTag<T extends Tag> extends Tag implements Iterable<T> {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param type Tag type of the list.
* @param value The value of the tag.
@ -54,6 +57,7 @@ public class ListTag<T extends Tag> extends Tag implements Iterable<T> {
/**
* Adds a tag to this list tag.
*
* @param tag Tag to add.
* @return If the list was changed as a result.
*/
@ -63,6 +67,7 @@ public class ListTag<T extends Tag> extends Tag implements Iterable<T> {
/**
* Removes a tag from this list tag.
*
* @param tag Tag to remove.
* @return If the list contained the tag.
*/
@ -72,6 +77,7 @@ public class ListTag<T extends Tag> extends Tag implements Iterable<T> {
/**
* Gets the tag at the given index of this list tag.
*
* @param index Index of the tag.
* @return The tag at the given index.
*/
@ -81,6 +87,7 @@ public class ListTag<T extends Tag> extends Tag implements Iterable<T> {
/**
* Gets the number of tags in this list tag.
*
* @return The size of this list tag.
*/
public int size() {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class LongTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public LongTag(String name) {
@ -21,6 +22,7 @@ public class LongTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -36,6 +38,7 @@ public class LongTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(long value) {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -13,6 +13,7 @@ public class ShortTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public ShortTag(String name) {
@ -21,6 +22,7 @@ public class ShortTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -36,6 +38,7 @@ public class ShortTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(short value) {

View File

@ -1,11 +1,11 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import org.spacehq.opennbt.NBTIO;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import ch.spacebase.opennbt.NBTIO;
/**
* A tag containing a string.
*/
@ -15,6 +15,7 @@ public class StringTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public StringTag(String name) {
@ -23,6 +24,7 @@ public class StringTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -38,6 +40,7 @@ public class StringTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(String value) {

View File

@ -1,4 +1,4 @@
package ch.spacebase.opennbt.tag;
package org.spacehq.opennbt.tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@ -7,7 +7,7 @@ import java.lang.reflect.Array;
/**
* Represents an NBT tag.
*
* <p/>
* All tags must have a constructor with a single string parameter for reading tags.
* Tags should also have setter methods specific to their value types.
*/
@ -17,6 +17,7 @@ public abstract class Tag implements Cloneable {
/**
* Creates a tag with the specified name.
*
* @param name The name.
*/
public Tag(String name) {
@ -25,6 +26,7 @@ public abstract class Tag implements Cloneable {
/**
* Gets the name of this tag.
*
* @return The name of this tag.
*/
public final String getName() {
@ -33,27 +35,31 @@ public abstract class Tag implements Cloneable {
/**
* Gets the value of this tag.
*
* @return The value of this tag.
*/
public abstract Object getValue();
/**
* Gets the type id of this tag.
*
* @return The tag's id.
*/
public abstract int getId();
/**
* Reads this tag from an input stream.
*
* @param in Stream to write to.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public abstract void read(DataInputStream in) throws IOException;
/**
* Writes this tag to an output stream.
*
* @param out Stream to write to.
* @throws IOException If an I/O error occurs.
* @throws java.io.IOException If an I/O error occurs.
*/
public abstract void write(DataOutputStream out) throws IOException;

View File

@ -1,11 +1,11 @@
package ch.spacebase.opennbt.tag.custom;
package org.spacehq.opennbt.tag.custom;
import org.spacehq.opennbt.tag.Tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import ch.spacebase.opennbt.tag.Tag;
/**
* A tag containing a double array.
*/
@ -15,6 +15,7 @@ public class DoubleArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public DoubleArrayTag(String name) {
@ -23,6 +24,7 @@ public class DoubleArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -38,6 +40,7 @@ public class DoubleArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(double[] value) {
@ -50,6 +53,7 @@ public class DoubleArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -59,6 +63,7 @@ public class DoubleArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -68,6 +73,7 @@ public class DoubleArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {

View File

@ -1,11 +1,11 @@
package ch.spacebase.opennbt.tag.custom;
package org.spacehq.opennbt.tag.custom;
import org.spacehq.opennbt.tag.Tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import ch.spacebase.opennbt.tag.Tag;
/**
* A tag containing a float array.
*/
@ -15,6 +15,7 @@ public class FloatArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public FloatArrayTag(String name) {
@ -23,6 +24,7 @@ public class FloatArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -38,6 +40,7 @@ public class FloatArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(float[] value) {
@ -50,6 +53,7 @@ public class FloatArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -59,6 +63,7 @@ public class FloatArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -68,6 +73,7 @@ public class FloatArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {

View File

@ -1,11 +1,11 @@
package ch.spacebase.opennbt.tag.custom;
package org.spacehq.opennbt.tag.custom;
import org.spacehq.opennbt.tag.Tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import ch.spacebase.opennbt.tag.Tag;
/**
* A tag containing a long array.
*/
@ -15,6 +15,7 @@ public class LongArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public LongArrayTag(String name) {
@ -23,6 +24,7 @@ public class LongArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -38,6 +40,7 @@ public class LongArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(long[] value) {
@ -50,6 +53,7 @@ public class LongArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -59,6 +63,7 @@ public class LongArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -68,6 +73,7 @@ public class LongArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {

View File

@ -1,13 +1,8 @@
package ch.spacebase.opennbt.tag.custom;
package org.spacehq.opennbt.tag.custom;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.spacehq.opennbt.tag.Tag;
import ch.spacebase.opennbt.tag.Tag;
import java.io.*;
/**
* A tag containing an array of serializable objects.
@ -18,6 +13,7 @@ public class SerializableArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public SerializableArrayTag(String name) {
@ -26,6 +22,7 @@ public class SerializableArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -41,6 +38,7 @@ public class SerializableArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(Serializable[] value) {
@ -53,6 +51,7 @@ public class SerializableArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -62,6 +61,7 @@ public class SerializableArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -71,6 +71,7 @@ public class SerializableArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {
@ -89,7 +90,7 @@ public class SerializableArrayTag extends Tag {
for(int index = 0; index < this.value.length; index++) {
try {
this.value[index] = (Serializable) str.readObject();
} catch (ClassNotFoundException e) {
} catch(ClassNotFoundException e) {
throw new IOException("Class not found while reading SerializableArrayTag!", e);
}
}

View File

@ -1,13 +1,8 @@
package ch.spacebase.opennbt.tag.custom;
package org.spacehq.opennbt.tag.custom;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.spacehq.opennbt.tag.Tag;
import ch.spacebase.opennbt.tag.Tag;
import java.io.*;
/**
* A tag containing a serializable object.
@ -18,6 +13,7 @@ public class SerializableTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public SerializableTag(String name) {
@ -26,6 +22,7 @@ public class SerializableTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -41,6 +38,7 @@ public class SerializableTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(Serializable value) {
@ -57,7 +55,7 @@ public class SerializableTag extends Tag {
ObjectInputStream str = new ObjectInputStream(in);
try {
this.value = (Serializable) str.readObject();
} catch (ClassNotFoundException e) {
} catch(ClassNotFoundException e) {
throw new IOException("Class not found while reading SerializableTag!", e);
}
}

View File

@ -1,11 +1,11 @@
package ch.spacebase.opennbt.tag.custom;
package org.spacehq.opennbt.tag.custom;
import org.spacehq.opennbt.tag.Tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import ch.spacebase.opennbt.tag.Tag;
/**
* A tag containing a short array.
*/
@ -15,6 +15,7 @@ public class ShortArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public ShortArrayTag(String name) {
@ -23,6 +24,7 @@ public class ShortArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -38,6 +40,7 @@ public class ShortArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(short[] value) {
@ -50,6 +53,7 @@ public class ShortArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -59,6 +63,7 @@ public class ShortArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -68,6 +73,7 @@ public class ShortArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {

View File

@ -1,12 +1,12 @@
package ch.spacebase.opennbt.tag.custom;
package org.spacehq.opennbt.tag.custom;
import org.spacehq.opennbt.NBTIO;
import org.spacehq.opennbt.tag.Tag;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import ch.spacebase.opennbt.NBTIO;
import ch.spacebase.opennbt.tag.Tag;
/**
* A tag containing a string array.
*/
@ -16,6 +16,7 @@ public class StringArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
*/
public StringArrayTag(String name) {
@ -24,6 +25,7 @@ public class StringArrayTag extends Tag {
/**
* Creates a tag with the specified name.
*
* @param name The name of the tag.
* @param value The value of the tag.
*/
@ -39,6 +41,7 @@ public class StringArrayTag extends Tag {
/**
* Sets the value of this tag.
*
* @param value New value of this tag.
*/
public void setValue(String[] value) {
@ -51,6 +54,7 @@ public class StringArrayTag extends Tag {
/**
* Gets a value in this tag's array.
*
* @param index Index of the value.
* @return The value at the given index.
*/
@ -60,6 +64,7 @@ public class StringArrayTag extends Tag {
/**
* Sets a value in this tag's array.
*
* @param index Index of the value.
* @param value Value to set.
*/
@ -69,6 +74,7 @@ public class StringArrayTag extends Tag {
/**
* Gets the length of this tag's array.
*
* @return This tag's array length.
*/
public int length() {