├── .gitignore ├── doc ├── package-list ├── resources │ ├── tab.gif │ ├── titlebar.gif │ ├── background.gif │ └── titlebar_end.gif ├── index.html ├── allclasses-noframe.html ├── org │ └── jnbt │ │ ├── package-frame.html │ │ ├── class-use │ │ ├── EndTag.html │ │ ├── IntTag.html │ │ ├── ByteTag.html │ │ ├── ListTag.html │ │ ├── LongTag.html │ │ ├── FloatTag.html │ │ ├── NBTUtils.html │ │ ├── ShortTag.html │ │ ├── DoubleTag.html │ │ ├── StringTag.html │ │ ├── CompoundTag.html │ │ ├── IntArrayTag.html │ │ ├── ByteArrayTag.html │ │ ├── NBTConstants.html │ │ ├── NBTInputStream.html │ │ └── NBTOutputStream.html │ │ ├── package-use.html │ │ └── package-tree.html ├── allclasses-frame.html ├── deprecated-list.html ├── index-files │ ├── index-11.html │ ├── index-15.html │ ├── index-12.html │ ├── index-5.html │ ├── index-3.html │ ├── index-1.html │ ├── index-8.html │ ├── index-13.html │ ├── index-9.html │ └── index-2.html └── overview-tree.html ├── JNBT_1.5.jar ├── _old └── JNBT_1.3.jar ├── .settings ├── org.eclipse.core.runtime.prefs ├── org.eclipse.core.resources.prefs └── org.eclipse.jdt.core.prefs ├── .classpath ├── .project ├── LICENSE.TXT ├── README.TXT └── src └── org └── jnbt ├── LongArrayTag.java ├── NBTConstants.java ├── EndTag.java ├── Tag.java ├── IntTag.java ├── ByteTag.java ├── ShortTag.java ├── LongTag.java ├── FloatTag.java ├── StringTag.java ├── DoubleTag.java ├── IntArrayTag.java ├── ByteArrayTag.java ├── CompoundTag.java ├── ListTag.java └── NBTUtils.java /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | -------------------------------------------------------------------------------- /doc/package-list: -------------------------------------------------------------------------------- 1 | org.jnbt 2 | -------------------------------------------------------------------------------- /JNBT_1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Morlok8k/JNBT/HEAD/JNBT_1.5.jar -------------------------------------------------------------------------------- /_old/JNBT_1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Morlok8k/JNBT/HEAD/_old/JNBT_1.3.jar -------------------------------------------------------------------------------- /doc/resources/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Morlok8k/JNBT/HEAD/doc/resources/tab.gif -------------------------------------------------------------------------------- /.settings/org.eclipse.core.runtime.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | line.separator=\r\n 3 | -------------------------------------------------------------------------------- /doc/resources/titlebar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Morlok8k/JNBT/HEAD/doc/resources/titlebar.gif -------------------------------------------------------------------------------- /doc/resources/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Morlok8k/JNBT/HEAD/doc/resources/background.gif -------------------------------------------------------------------------------- /doc/resources/titlebar_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Morlok8k/JNBT/HEAD/doc/resources/titlebar_end.gif -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/org/jnbt=UTF-8 3 | encoding/=UTF-8 4 | separateDerivedEncodings=true 5 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 4 | org.eclipse.jdt.core.compiler.compliance=1.6 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.6 8 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | JNBT 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Generated Documentation (Untitled) 7 | 18 | 19 | 20 | 21 | 22 | 23 | <noscript> 24 | <div>JavaScript is disabled on your browser.</div> 25 | </noscript> 26 | <h2>Frame Alert</h2> 27 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="org/jnbt/package-summary.html">Non-frame version</a>.</p> 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | JNBT License 2 | 3 | Copyright (c) 2010 Graham Edgecombe 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the JNBT team nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /README.TXT: -------------------------------------------------------------------------------- 1 | JNBT 1.5 Beta 2 | 3 | The original JNBT project seems to have been abandoned. 4 | This fork of JNBT has mainly added support for Tag_Int_Array 5 | 6 | Thanks to: 7 | Ancient (a.k.a. grahamedgecombe) - JNBT 1.0 and 1.1 8 | osici - for the TAG_Lists bug 9 | Jocopa3 - Initial Int-Array support 10 | Morlok8k - Maintaining the project 11 | peerkoel - Adding Long-Array support 12 | 13 | -------------- 14 | 15 | For more information about the license, see LICENSE.TXT. 16 | 17 | For more information about the project, see http://jnbt.sf.net/. 18 | 19 | -------------- 20 | 21 | JNBT: The Java NBT Library 22 | 23 | What is NBT? 24 | 25 | NBT, or Named Binary Tag, is a file format created by Markus Persson for use with Minecraft levels. Although originally designed for Minecraft levels, it is appropriate for the vast majority of use cases. 26 | 27 | What is JNBT? 28 | 29 | JNBT is a library that can read and write NBT files, written in Java by Graham Edgecombe and available open-source under the BSD license. 30 | 31 | -------------- 32 | 33 | Version History: 34 | 1.5 (peerkoel) 35 | - TAG_Long_Array support 36 | 37 | 1.4 38 | - (pruby) InputStream gzip/not-gziped support 39 | - (ensirius) Raw DataInputStream support 40 | 41 | 1.3 (Morlok8k) 42 | - Changed encoding of .java files to UTF-8 43 | - added "[JNBT]" to error output 44 | - added .equals and .hashcode to tags 45 | - cleaned source and formatting, etc... 46 | 47 | 1.2 (Morlok8k) 48 | - Tag_Int_Array Support 49 | 50 | 1.1 (grahamedgecombe) 51 | - fix for writing TAG_Lists 52 | - toString() methods on each tag type 53 | 54 | 1.0 (grahamedgecombe) 55 | - Initial Release 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/org/jnbt/LongArrayTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | import java.util.Arrays; 4 | import java.util.Locale; 5 | 6 | /** 7 | * The {@code TAG_Long_Array} tag. 8 | */ 9 | public class LongArrayTag extends Tag { 10 | 11 | private final long[] value; 12 | 13 | /** 14 | * Creates the tag. 15 | * 16 | * @param name The name. 17 | * @param value The value. 18 | */ 19 | public LongArrayTag(final String name, final long[] value) { 20 | super(name); 21 | this.value = value; 22 | } 23 | 24 | @Override 25 | public long[] getValue() { 26 | return value; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | StringBuilder hex = new StringBuilder(); 32 | for (long b : value) { 33 | String hexDigits = Long.toHexString(b).toUpperCase(Locale.ROOT); 34 | if (hexDigits.length() == 1) { 35 | hex.append("0"); 36 | } 37 | hex.append(hexDigits).append(" "); 38 | } 39 | return "TAG_Long_Array(" + hex + ")"; 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * 45 | * @see java.lang.Object#hashCode() 46 | */ 47 | @Override 48 | public int hashCode() { 49 | 50 | final int prime = 31; 51 | int result = super.hashCode(); 52 | result = (prime * result) + Arrays.hashCode(value); 53 | return result; 54 | } 55 | 56 | /* 57 | * (non-Javadoc) 58 | * 59 | * @see java.lang.Object#equals(java.lang.Object) 60 | */ 61 | @Override 62 | public boolean equals(final Object obj) { 63 | 64 | if (this == obj) { 65 | return true; 66 | } 67 | if (!super.equals(obj)) { 68 | return false; 69 | } 70 | if (!(obj instanceof LongArrayTag)) { 71 | return false; 72 | } 73 | final LongArrayTag other = (LongArrayTag) obj; 74 | if (!Arrays.equals(value, other.value)) { 75 | return false; 76 | } 77 | return true; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /doc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Classes 7 | 8 | 9 | 10 | 11 |

All Classes

12 |
13 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /doc/org/jnbt/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | org.jnbt 7 | 8 | 9 | 10 | 11 |

org.jnbt

12 |
13 |

Classes

14 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | All Classes 7 | 8 | 9 | 10 | 11 |

All Classes

12 |
13 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /src/org/jnbt/NBTConstants.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | import java.nio.charset.Charset; 41 | 42 | /** 43 | * A class which holds constant values. 44 | * 45 | * @author Graham Edgecombe, Jocopa3 46 | * 47 | */ 48 | public final class NBTConstants { 49 | 50 | /** 51 | * The character set used by NBT (UTF-8). 52 | */ 53 | public static final Charset CHARSET = Charset.forName("UTF-8"); 54 | 55 | /** 56 | * Tag type constants. 57 | */ 58 | public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, 59 | TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, 60 | TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9, 61 | TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11, TYPE_LONG_ARRAY = 12; 62 | 63 | /** 64 | * Default private constructor. 65 | */ 66 | private NBTConstants() { 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/org/jnbt/EndTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_End tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class EndTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final Object value = null; 52 | 53 | 54 | /** 55 | * Creates the tag. 56 | */ 57 | public EndTag() { 58 | 59 | super(""); 60 | } 61 | 62 | @Override 63 | public Object getValue() { 64 | 65 | return value; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | 71 | return "TAG_End"; 72 | } 73 | 74 | /* 75 | * (non-Javadoc) 76 | * @see java.lang.Object#hashCode() 77 | */ 78 | @Override 79 | public int hashCode() { 80 | 81 | final int prime = 31; 82 | int result = super.hashCode(); 83 | result = (prime * result) + ((value == null) ? 0 : value.hashCode()); 84 | return result; 85 | } 86 | 87 | /* 88 | * (non-Javadoc) 89 | * @see java.lang.Object#equals(java.lang.Object) 90 | */ 91 | @Override 92 | public boolean equals(final Object obj) { 93 | 94 | if (this == obj) { return true; } 95 | if (!super.equals(obj)) { return false; } 96 | if (!(obj instanceof EndTag)) { return false; } 97 | final EndTag other = (EndTag) obj; 98 | if (value == null) { 99 | if (other.value != null) { return false; } 100 | } else if (!value.equals(other.value)) { return false; } 101 | return true; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/org/jnbt/Tag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * Represents a single NBT tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public abstract class Tag { 47 | 48 | /** 49 | * The name of this tag. 50 | */ 51 | private final String name; 52 | 53 | /** 54 | * Creates the tag with the specified name. 55 | * 56 | * @param name 57 | * The name. 58 | */ 59 | public Tag(final String name) { 60 | 61 | this.name = name; 62 | } 63 | 64 | /** 65 | * Gets the name of this tag. 66 | * 67 | * @return The name of this tag. 68 | */ 69 | public final String getName() { 70 | 71 | return name; 72 | } 73 | 74 | /** 75 | * Gets the value of this tag. 76 | * 77 | * @return The value of this tag. 78 | */ 79 | public abstract Object getValue(); 80 | 81 | /* 82 | * (non-Javadoc) 83 | * @see java.lang.Object#hashCode() 84 | */ 85 | @Override 86 | public int hashCode() { 87 | 88 | final int prime = 31; 89 | int result = 1; 90 | result = (prime * result) + ((name == null) ? 0 : name.hashCode()); 91 | return result; 92 | } 93 | 94 | /* 95 | * (non-Javadoc) 96 | * @see java.lang.Object#equals(java.lang.Object) 97 | */ 98 | @Override 99 | public boolean equals(final Object obj) { 100 | 101 | if (this == obj) { return true; } 102 | if (obj == null) { return false; } 103 | if (!(obj instanceof Tag)) { return false; } 104 | final Tag other = (Tag) obj; 105 | if (name == null) { 106 | if (other.name != null) { return false; } 107 | } else if (!name.equals(other.name)) { return false; } 108 | return true; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/org/jnbt/IntTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_Int tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class IntTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final int value; 52 | 53 | /** 54 | * Creates the tag. 55 | * 56 | * @param name 57 | * The name. 58 | * @param value 59 | * The value. 60 | */ 61 | public IntTag(final String name, final int value) { 62 | 63 | super(name); 64 | this.value = value; 65 | } 66 | 67 | @Override 68 | public Integer getValue() { 69 | 70 | return value; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | 76 | final String name = getName(); 77 | String append = ""; 78 | if ((name != null) && !name.equals("")) { 79 | append = "(\"" + getName() + "\")"; 80 | } 81 | return "TAG_Int" + append + ": " + value; 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see java.lang.Object#hashCode() 87 | */ 88 | @Override 89 | public int hashCode() { 90 | 91 | final int prime = 31; 92 | int result = super.hashCode(); 93 | result = (prime * result) + value; 94 | return result; 95 | } 96 | 97 | /* 98 | * (non-Javadoc) 99 | * @see java.lang.Object#equals(java.lang.Object) 100 | */ 101 | @Override 102 | public boolean equals(final Object obj) { 103 | 104 | if (this == obj) { return true; } 105 | if (!super.equals(obj)) { return false; } 106 | if (!(obj instanceof IntTag)) { return false; } 107 | final IntTag other = (IntTag) obj; 108 | if (value != other.value) { return false; } 109 | return true; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/org/jnbt/ByteTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_Byte tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class ByteTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final byte value; 52 | 53 | /** 54 | * Creates the tag. 55 | * 56 | * @param name 57 | * The name. 58 | * @param value 59 | * The value. 60 | */ 61 | public ByteTag(final String name, final byte value) { 62 | 63 | super(name); 64 | this.value = value; 65 | } 66 | 67 | @Override 68 | public Byte getValue() { 69 | 70 | return value; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | 76 | final String name = getName(); 77 | String append = ""; 78 | if ((name != null) && !name.equals("")) { 79 | append = "(\"" + getName() + "\")"; 80 | } 81 | return "TAG_Byte" + append + ": " + value; 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see java.lang.Object#hashCode() 87 | */ 88 | @Override 89 | public int hashCode() { 90 | 91 | final int prime = 31; 92 | int result = super.hashCode(); 93 | result = (prime * result) + value; 94 | return result; 95 | } 96 | 97 | /* 98 | * (non-Javadoc) 99 | * @see java.lang.Object#equals(java.lang.Object) 100 | */ 101 | @Override 102 | public boolean equals(final Object obj) { 103 | 104 | if (this == obj) { return true; } 105 | if (!super.equals(obj)) { return false; } 106 | if (!(obj instanceof ByteTag)) { return false; } 107 | final ByteTag other = (ByteTag) obj; 108 | if (value != other.value) { return false; } 109 | return true; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/org/jnbt/ShortTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_Short tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class ShortTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final short value; 52 | 53 | /** 54 | * Creates the tag. 55 | * 56 | * @param name 57 | * The name. 58 | * @param value 59 | * The value. 60 | */ 61 | public ShortTag(final String name, final short value) { 62 | 63 | super(name); 64 | this.value = value; 65 | } 66 | 67 | @Override 68 | public Short getValue() { 69 | 70 | return value; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | 76 | final String name = getName(); 77 | String append = ""; 78 | if ((name != null) && !name.equals("")) { 79 | append = "(\"" + getName() + "\")"; 80 | } 81 | return "TAG_Short" + append + ": " + value; 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see java.lang.Object#hashCode() 87 | */ 88 | @Override 89 | public int hashCode() { 90 | 91 | final int prime = 31; 92 | int result = super.hashCode(); 93 | result = (prime * result) + value; 94 | return result; 95 | } 96 | 97 | /* 98 | * (non-Javadoc) 99 | * @see java.lang.Object#equals(java.lang.Object) 100 | */ 101 | @Override 102 | public boolean equals(final Object obj) { 103 | 104 | if (this == obj) { return true; } 105 | if (!super.equals(obj)) { return false; } 106 | if (!(obj instanceof ShortTag)) { return false; } 107 | final ShortTag other = (ShortTag) obj; 108 | if (value != other.value) { return false; } 109 | return true; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/org/jnbt/LongTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_Long tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class LongTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final long value; 52 | 53 | /** 54 | * Creates the tag. 55 | * 56 | * @param name 57 | * The name. 58 | * @param value 59 | * The value. 60 | */ 61 | public LongTag(final String name, final long value) { 62 | 63 | super(name); 64 | this.value = value; 65 | } 66 | 67 | @Override 68 | public Long getValue() { 69 | 70 | return value; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | 76 | final String name = getName(); 77 | String append = ""; 78 | if ((name != null) && !name.equals("")) { 79 | append = "(\"" + getName() + "\")"; 80 | } 81 | return "TAG_Long" + append + ": " + value; 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see java.lang.Object#hashCode() 87 | */ 88 | @Override 89 | public int hashCode() { 90 | 91 | final int prime = 31; 92 | int result = super.hashCode(); 93 | result = (prime * result) + (int) (value ^ (value >>> 32)); 94 | return result; 95 | } 96 | 97 | /* 98 | * (non-Javadoc) 99 | * @see java.lang.Object#equals(java.lang.Object) 100 | */ 101 | @Override 102 | public boolean equals(final Object obj) { 103 | 104 | if (this == obj) { return true; } 105 | if (!super.equals(obj)) { return false; } 106 | if (!(obj instanceof LongTag)) { return false; } 107 | final LongTag other = (LongTag) obj; 108 | if (value != other.value) { return false; } 109 | return true; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/org/jnbt/FloatTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_Float tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class FloatTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final float value; 52 | 53 | /** 54 | * Creates the tag. 55 | * 56 | * @param name 57 | * The name. 58 | * @param value 59 | * The value. 60 | */ 61 | public FloatTag(final String name, final float value) { 62 | 63 | super(name); 64 | this.value = value; 65 | } 66 | 67 | @Override 68 | public Float getValue() { 69 | 70 | return value; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | 76 | final String name = getName(); 77 | String append = ""; 78 | if ((name != null) && !name.equals("")) { 79 | append = "(\"" + getName() + "\")"; 80 | } 81 | return "TAG_Float" + append + ": " + value; 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see java.lang.Object#hashCode() 87 | */ 88 | @Override 89 | public int hashCode() { 90 | 91 | final int prime = 31; 92 | int result = super.hashCode(); 93 | result = (prime * result) + Float.floatToIntBits(value); 94 | return result; 95 | } 96 | 97 | /* 98 | * (non-Javadoc) 99 | * @see java.lang.Object#equals(java.lang.Object) 100 | */ 101 | @Override 102 | public boolean equals(final Object obj) { 103 | 104 | if (this == obj) { return true; } 105 | if (!super.equals(obj)) { return false; } 106 | if (!(obj instanceof FloatTag)) { return false; } 107 | final FloatTag other = (FloatTag) obj; 108 | if (Float.floatToIntBits(value) != Float.floatToIntBits(other.value)) { return false; } 109 | return true; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/org/jnbt/StringTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_String tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class StringTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final String value; 52 | 53 | /** 54 | * Creates the tag. 55 | * 56 | * @param name 57 | * The name. 58 | * @param value 59 | * The value. 60 | */ 61 | public StringTag(final String name, final String value) { 62 | 63 | super(name); 64 | this.value = value; 65 | } 66 | 67 | @Override 68 | public String getValue() { 69 | 70 | return value; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | 76 | final String name = getName(); 77 | String append = ""; 78 | if ((name != null) && !name.equals("")) { 79 | append = "(\"" + getName() + "\")"; 80 | } 81 | return "TAG_String" + append + ": " + value; 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see java.lang.Object#hashCode() 87 | */ 88 | @Override 89 | public int hashCode() { 90 | 91 | final int prime = 31; 92 | int result = super.hashCode(); 93 | result = (prime * result) + ((value == null) ? 0 : value.hashCode()); 94 | return result; 95 | } 96 | 97 | /* 98 | * (non-Javadoc) 99 | * @see java.lang.Object#equals(java.lang.Object) 100 | */ 101 | @Override 102 | public boolean equals(final Object obj) { 103 | 104 | if (this == obj) { return true; } 105 | if (!super.equals(obj)) { return false; } 106 | if (!(obj instanceof StringTag)) { return false; } 107 | final StringTag other = (StringTag) obj; 108 | if (value == null) { 109 | if (other.value != null) { return false; } 110 | } else if (!value.equals(other.value)) { return false; } 111 | return true; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/org/jnbt/DoubleTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * The TAG_Double tag. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class DoubleTag extends Tag { 47 | 48 | /** 49 | * The value. 50 | */ 51 | private final double value; 52 | 53 | /** 54 | * Creates the tag. 55 | * 56 | * @param name 57 | * The name. 58 | * @param value 59 | * The value. 60 | */ 61 | public DoubleTag(final String name, final double value) { 62 | 63 | super(name); 64 | this.value = value; 65 | } 66 | 67 | @Override 68 | public Double getValue() { 69 | 70 | return value; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | 76 | final String name = getName(); 77 | String append = ""; 78 | if ((name != null) && !name.equals("")) { 79 | append = "(\"" + getName() + "\")"; 80 | } 81 | return "TAG_Double" + append + ": " + value; 82 | } 83 | 84 | /* 85 | * (non-Javadoc) 86 | * @see java.lang.Object#hashCode() 87 | */ 88 | @Override 89 | public int hashCode() { 90 | 91 | final int prime = 31; 92 | int result = super.hashCode(); 93 | long temp; 94 | temp = Double.doubleToLongBits(value); 95 | result = (prime * result) + (int) (temp ^ (temp >>> 32)); 96 | return result; 97 | } 98 | 99 | /* 100 | * (non-Javadoc) 101 | * @see java.lang.Object#equals(java.lang.Object) 102 | */ 103 | @Override 104 | public boolean equals(final Object obj) { 105 | 106 | if (this == obj) { return true; } 107 | if (!super.equals(obj)) { return false; } 108 | if (!(obj instanceof DoubleTag)) { return false; } 109 | final DoubleTag other = (DoubleTag) obj; 110 | if (Double.doubleToLongBits(value) != Double 111 | .doubleToLongBits(other.value)) { return false; } 112 | return true; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /doc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Deprecated List 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Deprecated API

66 |

Contents

67 |
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/org/jnbt/IntArrayTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | import java.util.Arrays; 4 | 5 | //@formatter:off 6 | 7 | /* 8 | * JNBT License 9 | * 10 | * Copyright (c) 2010 Graham Edgecombe 11 | * All rights reserved. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions are met: 15 | * 16 | * * Redistributions of source code must retain the above copyright notice, 17 | * this list of conditions and the following disclaimer. 18 | * 19 | * * Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in the 21 | * documentation and/or other materials provided with the distribution. 22 | * 23 | * * Neither the name of the JNBT team nor the names of its 24 | * contributors may be used to endorse or promote products derived from 25 | * this software without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 31 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 | * POSSIBILITY OF SUCH DAMAGE. 38 | */ 39 | 40 | //@formatter:on 41 | 42 | /** 43 | * The TAG_Byte_Array tag. 44 | * 45 | * @author Jocopa3 46 | * 47 | */ 48 | public final class IntArrayTag extends Tag { 49 | 50 | /** 51 | * The value. 52 | */ 53 | private final int[] value; 54 | 55 | /** 56 | * Creates the tag. 57 | * 58 | * @param name 59 | * The name. 60 | * @param value 61 | * The value. 62 | */ 63 | public IntArrayTag(final String name, final int[] value) { 64 | 65 | super(name); 66 | this.value = value; 67 | } 68 | 69 | @Override 70 | public int[] getValue() { 71 | 72 | return value; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | 78 | final StringBuilder integers = new StringBuilder(); 79 | for (final int b : value) { 80 | integers.append(b).append(" "); 81 | } 82 | final String name = getName(); 83 | String append = ""; 84 | if ((name != null) && !name.equals("")) { 85 | append = "(\"" + getName() + "\")"; 86 | } 87 | return "TAG_Int_Array" + append + ": " + integers.toString(); 88 | } 89 | 90 | /* 91 | * (non-Javadoc) 92 | * @see java.lang.Object#hashCode() 93 | */ 94 | @Override 95 | public int hashCode() { 96 | 97 | final int prime = 31; 98 | int result = super.hashCode(); 99 | result = (prime * result) + Arrays.hashCode(value); 100 | return result; 101 | } 102 | 103 | /* 104 | * (non-Javadoc) 105 | * @see java.lang.Object#equals(java.lang.Object) 106 | */ 107 | @Override 108 | public boolean equals(final Object obj) { 109 | 110 | if (this == obj) { return true; } 111 | if (!super.equals(obj)) { return false; } 112 | if (!(obj instanceof IntArrayTag)) { return false; } 113 | final IntArrayTag other = (IntArrayTag) obj; 114 | if (!Arrays.equals(value, other.value)) { return false; } 115 | return true; 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/org/jnbt/ByteArrayTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | import java.util.Arrays; 41 | 42 | /** 43 | * The TAG_Byte_Array tag. 44 | * 45 | * @author Graham Edgecombe 46 | * 47 | */ 48 | public final class ByteArrayTag extends Tag { 49 | 50 | /** 51 | * The value. 52 | */ 53 | private final byte[] value; 54 | 55 | /** 56 | * Creates the tag. 57 | * 58 | * @param name 59 | * The name. 60 | * @param value 61 | * The value. 62 | */ 63 | public ByteArrayTag(final String name, final byte[] value) { 64 | 65 | super(name); 66 | this.value = value; 67 | } 68 | 69 | @Override 70 | public byte[] getValue() { 71 | 72 | return value; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | 78 | final StringBuilder hex = new StringBuilder(); 79 | for (final byte b : value) { 80 | final String hexDigits = Integer.toHexString(b).toUpperCase(); 81 | if (hexDigits.length() == 1) { 82 | hex.append("0"); 83 | } 84 | hex.append(hexDigits).append(" "); 85 | } 86 | final String name = getName(); 87 | String append = ""; 88 | if ((name != null) && !name.equals("")) { 89 | append = "(\"" + getName() + "\")"; 90 | } 91 | return "TAG_Byte_Array" + append + ": " + hex.toString(); 92 | } 93 | 94 | /* 95 | * (non-Javadoc) 96 | * @see java.lang.Object#hashCode() 97 | */ 98 | @Override 99 | public int hashCode() { 100 | 101 | final int prime = 31; 102 | int result = super.hashCode(); 103 | result = (prime * result) + Arrays.hashCode(value); 104 | return result; 105 | } 106 | 107 | /* 108 | * (non-Javadoc) 109 | * @see java.lang.Object#equals(java.lang.Object) 110 | */ 111 | @Override 112 | public boolean equals(final Object obj) { 113 | 114 | if (this == obj) { return true; } 115 | if (!super.equals(obj)) { return false; } 116 | if (!(obj instanceof ByteArrayTag)) { return false; } 117 | final ByteArrayTag other = (ByteArrayTag) obj; 118 | if (!Arrays.equals(value, other.value)) { return false; } 119 | return true; 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/EndTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.EndTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.EndTag

66 |
67 |
No usage of org.jnbt.EndTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/IntTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.IntTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.IntTag

66 |
67 |
No usage of org.jnbt.IntTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/ByteTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.ByteTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.ByteTag

66 |
67 |
No usage of org.jnbt.ByteTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/ListTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.ListTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.ListTag

66 |
67 |
No usage of org.jnbt.ListTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/LongTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.LongTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.LongTag

66 |
67 |
No usage of org.jnbt.LongTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/org/jnbt/CompoundTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | import java.util.Collections; 41 | import java.util.Map; 42 | 43 | /** 44 | * The TAG_Compound tag. 45 | * 46 | * @author Graham Edgecombe 47 | * 48 | */ 49 | public final class CompoundTag extends Tag { 50 | 51 | /** 52 | * The value. 53 | */ 54 | private final Map value; 55 | 56 | /** 57 | * Creates the tag. 58 | * 59 | * @param name 60 | * The name. 61 | * @param value 62 | * The value. 63 | */ 64 | public CompoundTag(final String name, final Map value) { 65 | 66 | super(name); 67 | this.value = Collections.unmodifiableMap(value); 68 | } 69 | 70 | @Override 71 | public Map getValue() { 72 | 73 | return value; 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | 79 | final String name = getName(); 80 | String append = ""; 81 | if ((name != null) && !name.equals("")) { 82 | append = "(\"" + getName() + "\")"; 83 | } 84 | final StringBuilder bldr = new StringBuilder(); 85 | bldr.append("TAG_Compound" + append + ": " + value.size() 86 | + " entries\r\n{\r\n"); 87 | for (final Map.Entry entry : value.entrySet()) { 88 | bldr.append(" " 89 | + entry.getValue().toString().replaceAll("\r\n", "\r\n ") 90 | + "\r\n"); 91 | } 92 | bldr.append("}"); 93 | return bldr.toString(); 94 | } 95 | 96 | /* 97 | * (non-Javadoc) 98 | * @see java.lang.Object#hashCode() 99 | */ 100 | @Override 101 | public int hashCode() { 102 | 103 | final int prime = 31; 104 | int result = super.hashCode(); 105 | result = (prime * result) + ((value == null) ? 0 : value.hashCode()); 106 | return result; 107 | } 108 | 109 | /* 110 | * (non-Javadoc) 111 | * @see java.lang.Object#equals(java.lang.Object) 112 | */ 113 | @Override 114 | public boolean equals(final Object obj) { 115 | 116 | if (this == obj) { return true; } 117 | if (!super.equals(obj)) { return false; } 118 | if (!(obj instanceof CompoundTag)) { return false; } 119 | final CompoundTag other = (CompoundTag) obj; 120 | if (value == null) { 121 | if (other.value != null) { return false; } 122 | } else if (!value.equals(other.value)) { return false; } 123 | return true; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/FloatTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.FloatTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.FloatTag

66 |
67 |
No usage of org.jnbt.FloatTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/NBTUtils.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.NBTUtils 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.NBTUtils

66 |
67 |
No usage of org.jnbt.NBTUtils
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/ShortTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.ShortTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.ShortTag

66 |
67 |
No usage of org.jnbt.ShortTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/DoubleTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.DoubleTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.DoubleTag

66 |
67 |
No usage of org.jnbt.DoubleTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/StringTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.StringTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.StringTag

66 |
67 |
No usage of org.jnbt.StringTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/CompoundTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.CompoundTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.CompoundTag

66 |
67 |
No usage of org.jnbt.CompoundTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/IntArrayTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.IntArrayTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.IntArrayTag

66 |
67 |
No usage of org.jnbt.IntArrayTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/ByteArrayTag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.ByteArrayTag 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.ByteArrayTag

66 |
67 |
No usage of org.jnbt.ByteArrayTag
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/NBTConstants.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.NBTConstants 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.NBTConstants

66 |
67 |
No usage of org.jnbt.NBTConstants
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/NBTInputStream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.NBTInputStream 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.NBTInputStream

66 |
67 |
No usage of org.jnbt.NBTInputStream
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /doc/org/jnbt/class-use/NBTOutputStream.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Class org.jnbt.NBTOutputStream 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Class
org.jnbt.NBTOutputStream

66 |
67 |
No usage of org.jnbt.NBTOutputStream
68 | 69 |
70 | 71 | 72 | 73 | 74 | 83 |
84 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/org/jnbt/ListTag.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | import java.util.Collections; 41 | import java.util.List; 42 | 43 | /** 44 | * The TAG_List tag. 45 | * 46 | * @author Graham Edgecombe 47 | * 48 | */ 49 | public final class ListTag extends Tag { 50 | 51 | /** 52 | * The type. 53 | */ 54 | private final Class type; 55 | 56 | /** 57 | * The value. 58 | */ 59 | private final List value; 60 | 61 | /** 62 | * Creates the tag. 63 | * 64 | * @param name 65 | * The name. 66 | * @param type 67 | * The type of item in the list. 68 | * @param value 69 | * The value. 70 | */ 71 | public ListTag(final String name, final Class type, final List value) { 72 | 73 | super(name); 74 | this.type = type; 75 | this.value = Collections.unmodifiableList(value); 76 | } 77 | 78 | /** 79 | * Gets the type of item in this list. 80 | * 81 | * @return The type of item in this list. 82 | */ 83 | public Class getType() { 84 | 85 | return type; 86 | } 87 | 88 | @Override 89 | public List getValue() { 90 | 91 | return value; 92 | } 93 | 94 | @Override 95 | public String toString() { 96 | 97 | final String name = getName(); 98 | String append = ""; 99 | if ((name != null) && !name.equals("")) { 100 | append = "(\"" + getName() + "\")"; 101 | } 102 | final StringBuilder bldr = new StringBuilder(); 103 | bldr.append("TAG_List" + append + ": " + value.size() 104 | + " entries of type " + NBTUtils.getTypeName(type) 105 | + "\r\n{\r\n"); 106 | for (final Tag t : value) { 107 | bldr.append(" " + t.toString().replaceAll("\r\n", "\r\n ") 108 | + "\r\n"); 109 | } 110 | bldr.append("}"); 111 | return bldr.toString(); 112 | } 113 | 114 | /* 115 | * (non-Javadoc) 116 | * @see java.lang.Object#hashCode() 117 | */ 118 | @Override 119 | public int hashCode() { 120 | 121 | final int prime = 31; 122 | int result = super.hashCode(); 123 | result = (prime * result) + ((value == null) ? 0 : value.hashCode()); 124 | return result; 125 | } 126 | 127 | /* 128 | * (non-Javadoc) 129 | * @see java.lang.Object#equals(java.lang.Object) 130 | */ 131 | @Override 132 | public boolean equals(final Object obj) { 133 | 134 | if (this == obj) { return true; } 135 | if (!super.equals(obj)) { return false; } 136 | if (!(obj instanceof ListTag)) { return false; } 137 | final ListTag other = (ListTag) obj; 138 | if (value == null) { 139 | if (other.value != null) { return false; } 140 | } else if (!value.equals(other.value)) { return false; } 141 | return true; 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /doc/org/jnbt/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Uses of Package org.jnbt 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Uses of Package
org.jnbt

66 |
67 |
68 |
    69 |
  • 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 82 | 83 | 84 |
    Classes in org.jnbt used by org.jnbt 
    Class and Description
    Tag 80 |
    Represents a single NBT tag.
    81 |
    85 |
  • 86 |
87 |
88 | 89 |
90 | 91 | 92 | 93 | 94 | 103 |
104 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /doc/index-files/index-11.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | O-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

O

68 |
69 |
org.jnbt - package org.jnbt
70 |
 
71 |
72 | B C D E F G H I L N O R S T W 
73 | 74 |
75 | 76 | 77 | 78 | 79 | 88 |
89 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /doc/index-files/index-15.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | W-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

W

68 |
69 |
writeTag(Tag) - Method in class org.jnbt.NBTOutputStream
70 |
71 |
Writes a tag.
72 |
73 |
74 | B C D E F G H I L N O R S T W 
75 | 76 |
77 | 78 | 79 | 80 | 81 | 90 |
91 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /doc/index-files/index-12.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | R-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

R

68 |
69 |
readTag() - Method in class org.jnbt.NBTInputStream
70 |
71 |
Reads an NBT tag from the stream.
72 |
73 |
74 | B C D E F G H I L N O R S T W 
75 | 76 |
77 | 78 | 79 | 80 | 81 | 90 |
91 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /doc/index-files/index-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | F-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

F

68 |
69 |
FloatTag - Class in org.jnbt
70 |
71 |
The TAG_Float tag.
72 |
73 |
FloatTag(String, float) - Constructor for class org.jnbt.FloatTag
74 |
75 |
Creates the tag.
76 |
77 |
78 | B C D E F G H I L N O R S T W 
79 | 80 |
81 | 82 | 83 | 84 | 85 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /doc/index-files/index-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | D-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

D

68 |
69 |
DoubleTag - Class in org.jnbt
70 |
71 |
The TAG_Double tag.
72 |
73 |
DoubleTag(String, double) - Constructor for class org.jnbt.DoubleTag
74 |
75 |
Creates the tag.
76 |
77 |
78 | B C D E F G H I L N O R S T W 
79 | 80 |
81 | 82 | 83 | 84 | 85 | 94 |
95 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /doc/index-files/index-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | B-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

B

68 |
69 |
ByteArrayTag - Class in org.jnbt
70 |
71 |
The TAG_Byte_Array tag.
72 |
73 |
ByteArrayTag(String, byte[]) - Constructor for class org.jnbt.ByteArrayTag
74 |
75 |
Creates the tag.
76 |
77 |
ByteTag - Class in org.jnbt
78 |
79 |
The TAG_Byte tag.
80 |
81 |
ByteTag(String, byte) - Constructor for class org.jnbt.ByteTag
82 |
83 |
Creates the tag.
84 |
85 |
86 | B C D E F G H I L N O R S T W 
87 | 88 |
89 | 90 | 91 | 92 | 93 | 102 |
103 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /doc/index-files/index-8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | I-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

I

68 |
69 |
IntArrayTag - Class in org.jnbt
70 |
71 |
The TAG_Byte_Array tag.
72 |
73 |
IntArrayTag(String, int[]) - Constructor for class org.jnbt.IntArrayTag
74 |
75 |
Creates the tag.
76 |
77 |
IntTag - Class in org.jnbt
78 |
79 |
The TAG_Int tag.
80 |
81 |
IntTag(String, int) - Constructor for class org.jnbt.IntTag
82 |
83 |
Creates the tag.
84 |
85 |
86 | B C D E F G H I L N O R S T W 
87 | 88 |
89 | 90 | 91 | 92 | 93 | 102 |
103 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /doc/index-files/index-13.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | S-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

S

68 |
69 |
ShortTag - Class in org.jnbt
70 |
71 |
The TAG_Short tag.
72 |
73 |
ShortTag(String, short) - Constructor for class org.jnbt.ShortTag
74 |
75 |
Creates the tag.
76 |
77 |
StringTag - Class in org.jnbt
78 |
79 |
The TAG_String tag.
80 |
81 |
StringTag(String, String) - Constructor for class org.jnbt.StringTag
82 |
83 |
Creates the tag.
84 |
85 |
86 | B C D E F G H I L N O R S T W 
87 | 88 |
89 | 90 | 91 | 92 | 93 | 102 |
103 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /doc/index-files/index-9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | L-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

L

68 |
69 |
ListTag - Class in org.jnbt
70 |
71 |
The TAG_List tag.
72 |
73 |
ListTag(String, Class<? extends Tag>, List<Tag>) - Constructor for class org.jnbt.ListTag
74 |
75 |
Creates the tag.
76 |
77 |
LongTag - Class in org.jnbt
78 |
79 |
The TAG_Long tag.
80 |
81 |
LongTag(String, long) - Constructor for class org.jnbt.LongTag
82 |
83 |
Creates the tag.
84 |
85 |
86 | B C D E F G H I L N O R S T W 
87 | 88 |
89 | 90 | 91 | 92 | 93 | 102 |
103 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /doc/index-files/index-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | C-Index 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
B C D E F G H I L N O R S T W  65 | 66 | 67 |

C

68 |
69 |
CHARSET - Static variable in class org.jnbt.NBTConstants
70 |
71 |
The character set used by NBT (UTF-8).
72 |
73 |
close() - Method in class org.jnbt.NBTInputStream
74 |
 
75 |
close() - Method in class org.jnbt.NBTOutputStream
76 |
 
77 |
CompoundTag - Class in org.jnbt
78 |
79 |
The TAG_Compound tag.
80 |
81 |
CompoundTag(String, Map<String, Tag>) - Constructor for class org.jnbt.CompoundTag
82 |
83 |
Creates the tag.
84 |
85 |
86 | B C D E F G H I L N O R S T W 
87 | 88 |
89 | 90 | 91 | 92 | 93 | 102 |
103 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /doc/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Class Hierarchy 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Hierarchy For All Packages

66 | Package Hierarchies: 67 | 70 |
71 |
72 |

Class Hierarchy

73 | 99 |
100 | 101 |
102 | 103 | 104 | 105 | 106 | 115 |
116 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /doc/org/jnbt/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | org.jnbt Class Hierarchy 7 | 8 | 9 | 10 | 11 | 17 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 35 |
36 | 63 | 64 |
65 |

Hierarchy For Package org.jnbt

66 |
67 |
68 |

Class Hierarchy

69 | 95 |
96 | 97 |
98 | 99 | 100 | 101 | 102 | 111 |
112 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /src/org/jnbt/NBTUtils.java: -------------------------------------------------------------------------------- 1 | package org.jnbt; 2 | 3 | //@formatter:off 4 | 5 | /* 6 | * JNBT License 7 | * 8 | * Copyright (c) 2010 Graham Edgecombe 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * 14 | * * Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 17 | * * Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 21 | * * Neither the name of the JNBT team nor the names of its 22 | * contributors may be used to endorse or promote products derived from 23 | * this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 29 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 | * POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | 38 | //@formatter:on 39 | 40 | /** 41 | * A class which contains NBT-related utility methods. 42 | * 43 | * @author Graham Edgecombe 44 | * 45 | */ 46 | public final class NBTUtils { 47 | 48 | /** 49 | * Gets the type name of a tag. 50 | * 51 | * @param clazz 52 | * The tag class. 53 | * @return The type name. 54 | */ 55 | public static String getTypeName(final Class clazz) { 56 | 57 | if (clazz.equals(ByteArrayTag.class)) { 58 | return "TAG_Byte_Array"; 59 | } else if (clazz.equals(ByteTag.class)) { 60 | return "TAG_Byte"; 61 | } else if (clazz.equals(CompoundTag.class)) { 62 | return "TAG_Compound"; 63 | } else if (clazz.equals(DoubleTag.class)) { 64 | return "TAG_Double"; 65 | } else if (clazz.equals(EndTag.class)) { 66 | return "TAG_End"; 67 | } else if (clazz.equals(FloatTag.class)) { 68 | return "TAG_Float"; 69 | } else if (clazz.equals(IntArrayTag.class)) { 70 | return "TAG_Int_Array"; 71 | } else if (clazz.equals(IntTag.class)) { 72 | return "TAG_Int"; 73 | } else if (clazz.equals(ListTag.class)) { 74 | return "TAG_List"; 75 | } else if (clazz.equals(LongTag.class)) { 76 | return "TAG_Long"; 77 | } else if (clazz.equals(ShortTag.class)) { 78 | return "TAG_Short"; 79 | } else if (clazz.equals(StringTag.class)) { 80 | return "TAG_String"; 81 | } else if (clazz.equals(LongArrayTag.class)) { 82 | return "TAG_Long_Array"; 83 | } else { 84 | throw new IllegalArgumentException("[JNBT] Invalid tag classs (" 85 | + clazz.getName() + ")."); 86 | } 87 | } 88 | 89 | /** 90 | * Gets the type code of a tag class. 91 | * 92 | * @param clazz 93 | * The tag class. 94 | * @return The type code. 95 | * @throws IllegalArgumentException 96 | * if the tag class is invalid. 97 | */ 98 | public static int getTypeCode(final Class clazz) { 99 | 100 | if (clazz.equals(ByteArrayTag.class)) { 101 | return NBTConstants.TYPE_BYTE_ARRAY; 102 | } else if (clazz.equals(ByteTag.class)) { 103 | return NBTConstants.TYPE_BYTE; 104 | } else if (clazz.equals(CompoundTag.class)) { 105 | return NBTConstants.TYPE_COMPOUND; 106 | } else if (clazz.equals(DoubleTag.class)) { 107 | return NBTConstants.TYPE_DOUBLE; 108 | } else if (clazz.equals(EndTag.class)) { 109 | return NBTConstants.TYPE_END; 110 | } else if (clazz.equals(FloatTag.class)) { 111 | return NBTConstants.TYPE_FLOAT; 112 | } else if (clazz.equals(IntArrayTag.class)) { 113 | return NBTConstants.TYPE_INT_ARRAY; 114 | } else if (clazz.equals(IntTag.class)) { 115 | return NBTConstants.TYPE_INT; 116 | } else if (clazz.equals(ListTag.class)) { 117 | return NBTConstants.TYPE_LIST; 118 | } else if (clazz.equals(LongTag.class)) { 119 | return NBTConstants.TYPE_LONG; 120 | } else if (clazz.equals(ShortTag.class)) { 121 | return NBTConstants.TYPE_SHORT; 122 | } else if (clazz.equals(StringTag.class)) { 123 | return NBTConstants.TYPE_STRING; 124 | } else if (clazz.equals(LongArrayTag.class)) { 125 | return NBTConstants.TYPE_LONG_ARRAY; 126 | } else { 127 | throw new IllegalArgumentException("[JNBT] Invalid tag classs (" 128 | + clazz.getName() + ")."); 129 | } 130 | } 131 | 132 | /** 133 | * Gets the class of a type of tag. 134 | * 135 | * @param type 136 | * The type. 137 | * @return The class. 138 | * @throws IllegalArgumentException 139 | * if the tag type is invalid. 140 | */ 141 | public static Class getTypeClass(final int type) { 142 | 143 | switch (type) 144 | { 145 | case NBTConstants.TYPE_END : 146 | return EndTag.class; 147 | case NBTConstants.TYPE_BYTE : 148 | return ByteTag.class; 149 | case NBTConstants.TYPE_SHORT : 150 | return ShortTag.class; 151 | case NBTConstants.TYPE_INT : 152 | return IntTag.class; 153 | case NBTConstants.TYPE_LONG : 154 | return LongTag.class; 155 | case NBTConstants.TYPE_FLOAT : 156 | return FloatTag.class; 157 | case NBTConstants.TYPE_DOUBLE : 158 | return DoubleTag.class; 159 | case NBTConstants.TYPE_BYTE_ARRAY : 160 | return ByteArrayTag.class; 161 | case NBTConstants.TYPE_STRING : 162 | return StringTag.class; 163 | case NBTConstants.TYPE_LIST : 164 | return ListTag.class; 165 | case NBTConstants.TYPE_COMPOUND : 166 | return CompoundTag.class; 167 | case NBTConstants.TYPE_INT_ARRAY : 168 | return IntArrayTag.class; 169 | case NBTConstants.TYPE_LONG_ARRAY: 170 | return LongArrayTag.class; 171 | default : 172 | throw new IllegalArgumentException( 173 | "[JNBT] Invalid tag type : " + type + "."); 174 | } 175 | } 176 | 177 | /** 178 | * Default private constructor. 179 | */ 180 | private NBTUtils() { 181 | 182 | } 183 | } 184 | --------------------------------------------------------------------------------