1/*
2 * Copyright (c) 2009-2010 jMonkeyEngine
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 *   notice, 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 'jMonkeyEngine' nor the names of its contributors
17 *   may be used to endorse or promote products derived from this software
18 *   without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33package com.jme3.export;
34
35import com.jme3.util.IntMap;
36import java.io.IOException;
37import java.nio.ByteBuffer;
38import java.nio.FloatBuffer;
39import java.nio.IntBuffer;
40import java.nio.ShortBuffer;
41import java.util.ArrayList;
42import java.util.BitSet;
43import java.util.Map;
44
45/**
46 * @author Joshua Slack
47 */
48public interface InputCapsule {
49
50    public int getSavableVersion(Class<? extends Savable> clazz);
51
52    // byte primitive
53
54    public byte readByte(String name, byte defVal) throws IOException;
55    public byte[] readByteArray(String name, byte[] defVal) throws IOException;
56    public byte[][] readByteArray2D(String name, byte[][] defVal) throws IOException;
57
58    // int primitive
59
60    public int readInt(String name, int defVal) throws IOException;
61    public int[] readIntArray(String name, int[] defVal) throws IOException;
62    public int[][] readIntArray2D(String name, int[][] defVal) throws IOException;
63
64
65    // float primitive
66
67    public float readFloat(String name, float defVal) throws IOException;
68    public float[] readFloatArray(String name, float[] defVal) throws IOException;
69    public float[][] readFloatArray2D(String name, float[][] defVal) throws IOException;
70
71
72    // double primitive
73
74    public double readDouble(String name, double defVal) throws IOException;
75    public double[] readDoubleArray(String name, double[] defVal) throws IOException;
76    public double[][] readDoubleArray2D(String name, double[][] defVal) throws IOException;
77
78
79    // long primitive
80
81    public long readLong(String name, long defVal) throws IOException;
82    public long[] readLongArray(String name, long[] defVal) throws IOException;
83    public long[][] readLongArray2D(String name, long[][] defVal) throws IOException;
84
85
86    // short primitive
87
88    public short readShort(String name, short defVal) throws IOException;
89    public short[] readShortArray(String name, short[] defVal) throws IOException;
90    public short[][] readShortArray2D(String name, short[][] defVal) throws IOException;
91
92
93    // boolean primitive
94
95    public boolean readBoolean(String name, boolean defVal) throws IOException;
96    public boolean[] readBooleanArray(String name, boolean[] defVal) throws IOException;
97    public boolean[][] readBooleanArray2D(String name, boolean[][] defVal) throws IOException;
98
99
100    // String
101
102    public String readString(String name, String defVal) throws IOException;
103    public String[] readStringArray(String name, String[] defVal) throws IOException;
104    public String[][] readStringArray2D(String name, String[][] defVal) throws IOException;
105
106
107    // BitSet
108
109    public BitSet readBitSet(String name, BitSet defVal) throws IOException;
110
111
112    // BinarySavable
113
114    public Savable readSavable(String name, Savable defVal) throws IOException;
115    public Savable[] readSavableArray(String name, Savable[] defVal) throws IOException;
116    public Savable[][] readSavableArray2D(String name, Savable[][] defVal) throws IOException;
117
118
119    // ArrayLists
120
121    public ArrayList readSavableArrayList(String name, ArrayList defVal) throws IOException;
122    public ArrayList[] readSavableArrayListArray(String name, ArrayList[] defVal) throws IOException;
123    public ArrayList[][] readSavableArrayListArray2D(String name, ArrayList[][] defVal) throws IOException;
124
125    public ArrayList<FloatBuffer> readFloatBufferArrayList(String name, ArrayList<FloatBuffer> defVal) throws IOException;
126    public ArrayList<ByteBuffer> readByteBufferArrayList(String name, ArrayList<ByteBuffer> defVal) throws IOException;
127
128
129    // Maps
130
131    public Map<? extends Savable, ? extends Savable> readSavableMap(String name, Map<? extends Savable, ? extends Savable> defVal) throws IOException;
132    public Map<String, ? extends Savable> readStringSavableMap(String name, Map<String, ? extends Savable> defVal) throws IOException;
133    public IntMap<? extends Savable> readIntSavableMap(String name, IntMap<? extends Savable> defVal) throws IOException;
134
135    // NIO BUFFERS
136    // float buffer
137
138    public FloatBuffer readFloatBuffer(String name, FloatBuffer defVal) throws IOException;
139
140
141    // int buffer
142
143    public IntBuffer readIntBuffer(String name, IntBuffer defVal) throws IOException;
144
145
146    // byte buffer
147
148    public ByteBuffer readByteBuffer(String name, ByteBuffer defVal) throws IOException;
149
150
151    // short buffer
152
153    public ShortBuffer readShortBuffer(String name, ShortBuffer defVal) throws IOException;
154
155
156    // enums
157
158    public <T extends Enum<T>> T readEnum(String name, Class<T> enumType, T defVal) throws IOException;
159
160}