diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java
index 062c8b04..675c1b92 100644
--- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java
+++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/assets/loaders/CubemapLoader.java
@@ -10,7 +10,6 @@
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
-import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.utils.Array;
/** {@link AssetLoader} for {@link Cubemap} instances. The pixel data is loaded asynchronously. The texture is then created on the
diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java
index b1316ad0..82c43fff 100644
--- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java
+++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/Pixmap.java
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,10 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.html.CanvasPixelArray;
+import org.w3c.dom.html.CanvasRenderingContext2D;
+import org.w3c.dom.html.HTMLCanvasElement;
+import org.w3c.dom.html.Window;
import com.badlogic.gdx.backends.dragome.DragomeFileHandle;
import com.badlogic.gdx.files.FileHandle;
@@ -31,54 +35,71 @@
import com.badlogic.gdx.utils.GdxRuntimeException;
import com.dragome.services.WebServiceLocator;
import com.dragome.web.enhancers.jsdelegate.JsDelegateFactory;
-import com.dragome.web.html.dom.html5canvas.interfaces.CanvasPixelArray;
-import com.dragome.web.html.dom.html5canvas.interfaces.CanvasRenderingContext2D;
-import com.dragome.web.html.dom.html5canvas.interfaces.HTMLCanvasElement;
-import com.dragome.web.html.dom.html5canvas.interfaces.ImageElement;
+import com.dragome.web.html.dom.w3c.HTMLImageElementExtension;
-public class Pixmap implements Disposable {
- public static Map
* Uses indirect Buffers on Android 1.5/1.6 to fix GC invocation due to leaking PlatformAddress instances. *
- * + * ** You can also use this to store indices for vertex arrays. Do not call {@link #bind()} or {@link #unbind()} in this case but * rather use {@link #getBuffer()} to use the buffer directly with glDrawElements. You must also create the IndexBufferObject with * the second constructor and specify isDirect as true as glDrawElements in conjunction with vertex arrays needs direct buffers. *
- * + * ** VertexBufferObjects must be disposed via the {@link #dispose()} method when no longer needed *
- * + * * @author mzechner */ public class IndexBufferObject implements IndexData { ShortBuffer buffer; @@ -52,7 +52,7 @@ public class IndexBufferObject implements IndexData { final int usage; /** Creates a new IndexBufferObject. - * + * * @param isStatic whether the index buffer is static * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObject (boolean isStatic, int maxIndices) { @@ -64,7 +64,7 @@ public IndexBufferObject (boolean isStatic, int maxIndices) { } /** Creates a new IndexBufferObject to be used with vertex arrays. - * + * * @param maxIndices the maximum number of indices this buffer can hold */ public IndexBufferObject (int maxIndices) { this.isDirect = true; @@ -88,11 +88,11 @@ public int getNumMaxIndices () { * Sets the indices of this IndexBufferObject, discarding the old indices. The count must equal the number of indices to be * copied to this IndexBufferObject. * - * + * ** This can be called in between calls to {@link #bind()} and {@link #unbind()}. The index data will be updated instantly. *
- * + * * @param indices the vertex data * @param offset the offset to start copying the data from * @param count the number of shorts to copy */ @@ -107,20 +107,19 @@ public void setIndices (short[] indices, int offset, int count) { isDirty = false; } } - + public void setIndices (ShortBuffer indices) { isDirty = true; buffer.clear(); buffer.put(indices); buffer.flip(); - + if (isBound) { Gdx.gl20.glBufferData(GL20.GL_ELEMENT_ARRAY_BUFFER, buffer.limit(), buffer, usage); isDirty = false; } } - @Override public void updateIndices (int targetOffset, short[] indices, int offset, int count) { isDirty = true; final int pos = buffer.position(); @@ -138,7 +137,7 @@ public void updateIndices (int targetOffset, short[] indices, int offset, int co * Returns the underlying ShortBuffer. If you modify the buffer contents they wil be uploaded on the call to {@link #bind()}. * If you need immediate uploading use {@link #setIndices(short[], int, int)}. * - * + * * @return the underlying short buffer. */ public ShortBuffer getBuffer () { isDirty = true; @@ -174,6 +173,6 @@ public void dispose () { GL20 gl = Gdx.gl20; gl.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0); gl.glDeleteBuffer(bufferHandle); - bufferHandle = 0; + bufferHandle = 0; } } diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java index 76fd8079..32ab9823 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/glutils/VertexBufferObjectWithVAO.java @@ -1,6 +1,5 @@ package com.badlogic.gdx.graphics.glutils; -import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java index 8607c4c2..2c5c4fe6 100644 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java +++ b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/graphics/profiling/GLErrorListener.java @@ -16,9 +16,10 @@ package com.badlogic.gdx.graphics.profiling; +import static com.badlogic.gdx.graphics.profiling.GLProfiler.resolveErrorNumber; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.GdxRuntimeException; -import static com.badlogic.gdx.graphics.profiling.GLProfiler.resolveErrorNumber; /** @see GLProfiler * @author Jan Polák */ diff --git a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/utils/Utf8Decoder.java b/backends/gdx-backend-dragome/emu/com/badlogic/gdx/utils/Utf8Decoder.java deleted file mode 100644 index 86217721..00000000 --- a/backends/gdx-backend-dragome/emu/com/badlogic/gdx/utils/Utf8Decoder.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright 2015 See AUTHORS file. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ - -/******************************************************************************* - * Copyright (c) 2008-2009 Bjoern Hoehrmann- * This abstract class does not provide a fully working implementation, so it needs to be subclassed, and at least the - * {@link #read(char[], int, int)} and {@link #close()} methods needs to be overridden. Overriding some of the non-abstract - * methods is also often advised, since it might result in higher efficiency. - *
- * Many specialized readers for purposes like reading from a file already exist in this package. - * - * @see Writer */ -public abstract class Reader implements Readable, Closeable { - /*** The object used to synchronize access to the reader. */ - protected Object lock; - - /*** Constructs a new {@code Reader} with {@code this} as the object used to synchronize critical sections. */ - protected Reader () { - super(); - lock = this; - } - - /*** Constructs a new {@code Reader} with {@code lock} used to synchronize critical sections. - * - * @param lock the {@code Object} used to synchronize critical sections. - * @throws NullPointerException if {@code lock} is {@code null}. */ - protected Reader (Object lock) { - if (lock == null) { - throw new NullPointerException(); - } - this.lock = lock; - } - - /*** Closes this reader. Implementations of this method should free any resources associated with the reader. - * - * @throws IOException if an error occurs while closing this reader. */ - public abstract void close () throws IOException; - - /*** Sets a mark position in this reader. The parameter {@code readLimit} indicates how many characters can be read before the - * mark is invalidated. Calling {@code reset()} will reposition the reader back to the marked position if {@code readLimit} has - * not been surpassed. - *
- * This default implementation simply throws an {@code IOException}; subclasses must provide their own implementation. - * - * @param readLimit the number of characters that can be read before the mark is invalidated. - * @throws IllegalArgumentException if {@code readLimit < 0}. - * @throws IOException if an error occurs while setting a mark in this reader. - * @see #markSupported() - * @see #reset() */ - public void mark (int readLimit) throws IOException { - throw new IOException(); - } - - /*** Indicates whether this reader supports the {@code mark()} and {@code reset()} methods. This default implementation returns - * {@code false}. - * - * @return always {@code false}. */ - public boolean markSupported () { - return false; - } - - /*** Reads a single character from this reader and returns it as an integer with the two higher-order bytes set to 0. Returns -1 - * if the end of the reader has been reached. - * - * @return the character read or -1 if the end of the reader has been reached. - * @throws IOException if this reader is closed or some other I/O error occurs. */ - public int read () throws IOException { - synchronized (lock) { - char charArray[] = new char[1]; - if (read(charArray, 0, 1) != -1) { - return charArray[0]; - } - return -1; - } - } - - /*** Reads characters from this reader and stores them in the character array {@code buf} starting at offset 0. Returns the - * number of characters actually read or -1 if the end of the reader has been reached. - * - * @param buf character array to store the characters read. - * @return the number of characters read or -1 if the end of the reader has been reached. - * @throws IOException if this reader is closed or some other I/O error occurs. */ - public int read (char buf[]) throws IOException { - return read(buf, 0, buf.length); - } - - /*** Reads at most {@code count} characters from this reader and stores them at {@code offset} in the character array {@code buf} - * . Returns the number of characters actually read or -1 if the end of the reader has been reached. - * - * @param buf the character array to store the characters read. - * @param offset the initial position in {@code buffer} to store the characters read from this reader. - * @param count the maximum number of characters to read. - * @return the number of characters read or -1 if the end of the reader has been reached. - * @throws IOException if this reader is closed or some other I/O error occurs. */ - public abstract int read (char buf[], int offset, int count) throws IOException; - - /*** Indicates whether this reader is ready to be read without blocking. Returns {@code true} if this reader will not block when - * {@code read} is called, {@code false} if unknown or blocking will occur. This default implementation always returns - * {@code false}. - * - * @return always {@code false}. - * @throws IOException if this reader is closed or some other I/O error occurs. - * @see #read() - * @see #read(char[]) - * @see #read(char[], int, int) */ - public boolean ready () throws IOException { - return false; - } - - /*** Resets this reader's position to the last {@code mark()} location. Invocations of {@code read()} and {@code skip()} will - * occur from this new location. If this reader has not been marked, the behavior of {@code reset()} is implementation - * specific. This default implementation throws an {@code IOException}. - * - * @throws IOException always thrown in this default implementation. - * @see #mark(int) - * @see #markSupported() */ - public void reset () throws IOException { - throw new IOException(); - } - - /*** Skips {@code amount} characters in this reader. Subsequent calls of {@code read} methods will not return these characters - * unless {@code reset()} is used. This method may perform multiple reads to read {@code count} characters. - * - * @param count the maximum number of characters to skip. - * @return the number of characters actually skipped. - * @throws IllegalArgumentException if {@code amount < 0}. - * @throws IOException if this reader is closed or some other I/O error occurs. - * @see #mark(int) - * @see #markSupported() - * @see #reset() */ - public long skip (long count) throws IOException { - if (count < 0) { - throw new IllegalArgumentException(); - } - synchronized (lock) { - long skipped = 0; - int toRead = count < 512 ? (int)count : 512; - char charsSkipped[] = new char[toRead]; - while (skipped < count) { - int read = read(charsSkipped, 0, toRead); - if (read == -1) { - return skipped; - } - skipped += read; - if (read < toRead) { - return skipped; - } - if (count - skipped < toRead) { - toRead = (int)(count - skipped); - } - } - return skipped; - } - } - - /*** Reads characters and puts them into the {@code target} character buffer. - * - * @param target the destination character buffer. - * @return the number of characters put into {@code target} or -1 if the end of this reader has been reached before a character - * has been read. - * @throws IOException if any I/O error occurs while reading from this reader. - * @throws NullPointerException if {@code target} is {@code null}. - * @throws ReadOnlyBufferException if {@code target} is read-only. */ - public int read (CharBuffer target) throws IOException { - if (null == target) { - throw new NullPointerException(); - } - int length = target.length(); - char[] buf = new char[length]; - length = Math.min(length, read(buf)); - if (length > 0) { - target.put(buf, 0, length); - } - return length; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/StringReader.java b/backends/gdx-backend-dragome/emu/java/io/StringReader.java deleted file mode 100644 index c2247d1d..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/StringReader.java +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2008, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package java.io; - -public class StringReader extends Reader { - private final String in; - private int position = 0; - - public StringReader (String in) { - this.in = in; - } - - public int read (char[] b, int offset, int length) throws IOException { - if (length > in.length() - position) { - length = in.length() - position; - if (length <= 0) { - return -1; - } - } - in.getChars(position, position + length, b, offset); - position += length; - return length; - } - - public void close () throws IOException { - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/StringWriter.java b/backends/gdx-backend-dragome/emu/java/io/StringWriter.java deleted file mode 100644 index cbf0703d..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/StringWriter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2008, Avian Contributors - - Permission to use, copy, modify, and/or distribute this software - for any purpose with or without fee is hereby granted, provided - that the above copyright notice and this permission notice appear - in all copies. - - There is NO WARRANTY for this software. See license.txt for - details. */ - -package java.io; - -public class StringWriter extends Writer { - private final StringBuilder out; - - public StringWriter() { - out = new StringBuilder(); - } - - public StringWriter(int initialCapacity) { - out = new StringBuilder(initialCapacity); - } - - public void write (char[] b, int offset, int length) throws IOException { - out.append(b, offset, length); - } - - public String toString () { - return out.toString(); - } - - public void flush () throws IOException { - } - - public void close () throws IOException { - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/UTFDataFormatException.java b/backends/gdx-backend-dragome/emu/java/io/UTFDataFormatException.java deleted file mode 100644 index b0076e65..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/UTFDataFormatException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class UTFDataFormatException extends IOException { - - public UTFDataFormatException (String msg) { - super(msg); - } - - public UTFDataFormatException () { - super(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/UnsupportedEncodingException.java b/backends/gdx-backend-dragome/emu/java/io/UnsupportedEncodingException.java deleted file mode 100644 index f0f81510..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/UnsupportedEncodingException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.io; - -public class UnsupportedEncodingException extends IOException { - public UnsupportedEncodingException () { - super(); - } - - public UnsupportedEncodingException (String s) { - super(s); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/io/Writer.java b/backends/gdx-backend-dragome/emu/java/io/Writer.java deleted file mode 100644 index 8f07bb63..00000000 --- a/backends/gdx-backend-dragome/emu/java/io/Writer.java +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.io; - -/*** The base class for all writers. A writer is a means of writing data to a target in a character-wise manner. Most output streams - * expect the {@link #flush()} method to be called before closing the stream, to ensure all data is actually written out. - *
- * This abstract class does not provide a fully working implementation, so it needs to be subclassed, and at least the - * {@link #write(char[], int, int)}, {@link #close()} and {@link #flush()} methods needs to be overridden. Overriding some of the - * non-abstract methods is also often advised, since it might result in higher efficiency. - *
- * Many specialized readers for purposes like reading from a file already exist in this package. - * - * @see Reader */ -public abstract class Writer implements Appendable, Closeable, Flushable { - - static final String TOKEN_NULL = "null"; //$NON-NLS-1$ - - /*** The object used to synchronize access to the writer. */ - protected Object lock; - - /*** Constructs a new {@code Writer} with {@code this} as the object used to synchronize critical sections. */ - protected Writer () { - super(); - lock = this; - } - - /*** Constructs a new {@code Writer} with {@code lock} used to synchronize critical sections. - * - * @param lock the {@code Object} used to synchronize critical sections. - * @throws NullPointerException if {@code lock} is {@code null}. */ - protected Writer (Object lock) { - if (lock == null) { - throw new NullPointerException(); - } - this.lock = lock; - } - - /*** Closes this writer. Implementations of this method should free any resources associated with the writer. - * - * @throws IOException if an error occurs while closing this writer. */ - public abstract void close () throws IOException; - - /*** Flushes this writer. Implementations of this method should ensure that all buffered characters are written to the target. - * - * @throws IOException if an error occurs while flushing this writer. */ - public abstract void flush () throws IOException; - - /*** Writes the entire character buffer {@code buf} to the target. - * - * @param buf the non-null array containing characters to write. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public void write (char buf[]) throws IOException { - write(buf, 0, buf.length); - } - - /*** Writes {@code count} characters starting at {@code offset} in {@code buf} to the target. - * - * @param buf the non-null character array to write. - * @param offset the index of the first character in {@code buf} to write. - * @param count the maximum number of characters to write. - * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code count < 0}, or if {@code offset + count} is greater than - * the size of {@code buf}. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public abstract void write (char buf[], int offset, int count) throws IOException; - - /*** Writes one character to the target. Only the two least significant bytes of the integer {@code oneChar} are written. - * - * @param oneChar the character to write to the target. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public void write (int oneChar) throws IOException { - synchronized (lock) { - char oneCharArray[] = new char[1]; - oneCharArray[0] = (char)oneChar; - write(oneCharArray); - } - } - - /*** Writes the characters from the specified string to the target. - * - * @param str the non-null string containing the characters to write. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public void write (String str) throws IOException { - write(str, 0, str.length()); - } - - /*** Writes {@code count} characters from {@code str} starting at {@code offset} to the target. - * - * @param str the non-null string containing the characters to write. - * @param offset the index of the first character in {@code str} to write. - * @param count the number of characters from {@code str} to write. - * @throws IOException if this writer is closed or another I/O error occurs. - * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code count < 0}, or if {@code offset + count} is greater than - * the length of {@code str}. */ - public void write (String str, int offset, int count) throws IOException { - if (count < 0) { // other cases tested by getChars() - throw new StringIndexOutOfBoundsException(); - } - char buf[] = new char[count]; - str.getChars(offset, offset + count, buf, 0); - - synchronized (lock) { - write(buf, 0, buf.length); - } - } - - /*** Appends the character {@code c} to the target. This method works the same way as {@link #write(int)}. - * - * @param c the character to append to the target stream. - * @return this writer. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public Writer append (char c) throws IOException { - write(c); - return this; - } - - /*** Appends the character sequence {@code csq} to the target. This method works the same way as - * {@code Writer.write(csq.toString())}. If {@code csq} is {@code null}, then the string "null" is written to the target - * stream. - * - * @param csq the character sequence appended to the target. - * @return this writer. - * @throws IOException if this writer is closed or another I/O error occurs. */ - public Writer append (CharSequence csq) throws IOException { - if (null == csq) { - write(TOKEN_NULL); - } else { - write(csq.toString()); - } - return this; - } - - /*** Appends a subsequence of the character sequence {@code csq} to the target. This method works the same way as - * {@code Writer.writer(csq.subsequence(start, end).toString())}. If {@code csq} is {@code null}, then the specified - * subsequence of the string "null" will be written to the target. - * - * @param csq the character sequence appended to the target. - * @param start the index of the first char in the character sequence appended to the target. - * @param end the index of the character following the last character of the subsequence appended to the target. - * @return this writer. - * @throws IOException if this writer is closed or another I/O error occurs. - * @throws IndexOutOfBoundsException if {@code start > end}, {@code start < 0}, {@code end < 0} or either {@code start} or - * {@code end} are greater or equal than the length of {@code csq}. */ - public Writer append (CharSequence csq, int start, int end) throws IOException { - if (null == csq) { - write(TOKEN_NULL.substring(start, end)); - } else { - write(csq.subSequence(start, end).toString()); - } - return this; - } - - /*** Returns true if this writer has encountered and suppressed an error. Used by PrintWriters as an alternative to checked - * exceptions. */ - boolean checkError () { - return false; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/net/URLEncoder.java b/backends/gdx-backend-dragome/emu/java/net/URLEncoder.java deleted file mode 100644 index ab19aca3..00000000 --- a/backends/gdx-backend-dragome/emu/java/net/URLEncoder.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.net; - -import java.io.UnsupportedEncodingException; - -/** - * This class is used to encode a string using the format required by - * {@code application/x-www-form-urlencoded} MIME content type. - */ -public class URLEncoder { - - static final String digits = "0123456789ABCDEF"; - - /** - * Prevents this class from being instantiated. - */ - private URLEncoder() { - } - - /** - * Encodes a given string {@code s} in a x-www-form-urlencoded string using - * the specified encoding scheme {@code enc}. - *
- * All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') - * and characters '.', '-', '*', '_' are converted into their hexadecimal - * value prepended by '%'. For example: '#' -> %23. In addition, spaces are - * substituted by '+' - * - * @param s - * the string to be encoded. - * @return the encoded string. - * @deprecated use {@link #encode(String, String)} instead. - */ - @Deprecated - public static String encode(String s) { - // Guess a bit bigger for encoded form - StringBuilder buf = new StringBuilder(s.length() + 16); - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') - || (ch >= '0' && ch <= '9') || ".-*_".indexOf(ch) > -1) { - buf.append(ch); - } else if (ch == ' ') { - buf.append('+'); - } else { - byte[] bytes = new String(new char[] { ch }).getBytes(); - for (int j = 0; j < bytes.length; j++) { - buf.append('%'); - buf.append(digits.charAt((bytes[j] & 0xf0) >> 4)); - buf.append(digits.charAt(bytes[j] & 0xf)); - } - } - } - return buf.toString(); - } - - /** - * Encodes the given string {@code s} in a x-www-form-urlencoded string - * using the specified encoding scheme {@code enc}. - *
- * All characters except letters ('a'..'z', 'A'..'Z') and numbers ('0'..'9') - * and characters '.', '-', '*', '_' are converted into their hexadecimal - * value prepended by '%'. For example: '#' -> %23. In addition, spaces are - * substituted by '+' - * - * @param s - * the string to be encoded. - * @param enc - * the encoding scheme to be used. - * @return the encoded string. - * @throws UnsupportedEncodingException - * if the specified encoding scheme is invalid. - */ - public static String encode(String s, String enc) throws UnsupportedEncodingException { - if (s == null || enc == null) { - throw new NullPointerException(); - } - // check for UnsupportedEncodingException - "".getBytes(enc); - - // Guess a bit bigger for encoded form - StringBuilder buf = new StringBuilder(s.length() + 16); - int start = -1; - for (int i = 0; i < s.length(); i++) { - char ch = s.charAt(i); - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') - || (ch >= '0' && ch <= '9') || " .-*_".indexOf(ch) > -1) { - if (start >= 0) { - convert(s.substring(start, i), buf, enc); - start = -1; - } - if (ch != ' ') { - buf.append(ch); - } else { - buf.append('+'); - } - } else { - if (start < 0) { - start = i; - } - } - } - if (start >= 0) { - convert(s.substring(start, s.length()), buf, enc); - } - return buf.toString(); - } - - private static void convert(String s, StringBuilder buf, String enc) - throws UnsupportedEncodingException { - byte[] bytes = s.getBytes(enc); - for (int j = 0; j < bytes.length; j++) { - buf.append('%'); - buf.append(digits.charAt((bytes[j] & 0xf0) >> 4)); - buf.append(digits.charAt(bytes[j] & 0xf)); - } - } -} \ No newline at end of file diff --git a/backends/gdx-backend-dragome/emu/java/nio/BaseByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/BaseByteBuffer.java deleted file mode 100644 index 9c78c2a6..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/BaseByteBuffer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** Serves as the root of other byte buffer impl classes, implements common methods that can be shared by child classes. */ -abstract class BaseByteBuffer extends ByteBuffer { - - protected BaseByteBuffer (int capacity) { - super(capacity); - } - - @Override - public CharBuffer asCharBuffer () { - return CharToByteBufferAdapter.wrap(this); - } - - @Override - public DoubleBuffer asDoubleBuffer () { - return DoubleToByteBufferAdapter.wrap(this); - } - - @Override - public FloatBuffer asFloatBuffer () { - return FloatToByteBufferAdapter.wrap(this); - } - - @Override - public IntBuffer asIntBuffer () { - return IntToByteBufferAdapter.wrap(this); - } - - @Override - public LongBuffer asLongBuffer () { - return LongToByteBufferAdapter.wrap(this); - } - - @Override - public ShortBuffer asShortBuffer () { - return ShortToByteBufferAdapter.wrap(this); - } - - public final char getChar () { - return (char)getShort(); - } - - public final char getChar (int index) { - return (char)getShort(index); - } - - public final ByteBuffer putChar (char value) { - return putShort((short)value); - } - - public final ByteBuffer putChar (int index, char value) { - return putShort(index, (short)value); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/Buffer.java b/backends/gdx-backend-dragome/emu/java/nio/Buffer.java deleted file mode 100644 index 9e36157f..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/Buffer.java +++ /dev/null @@ -1,232 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer is a list of elements of a specific primitive type. - *
- * A buffer can be described by the following properties: - *
limit - 1
. Accessing elements out of the scope will cause an exception. Limit may not be negative and not greater
- * than capacity.ReadOnlyBufferException
, while changing the position, limit and mark of a read-only buffer is OK.- * Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take - * care of the synchronization issues. - *
- * - * @since Android 1.0 */ -public abstract class Buffer { - - /**UNSET_MARK
means the mark has not been set. */
- final static int UNSET_MARK = -1;
-
- /** The capacity of this buffer, which never change. */
- final int capacity;
-
- /** limit - 1
is the last element that can be read or written. Limit must be no less than zero and no greater than
- * capacity
. */
- int limit;
-
- /** Mark is where position will be set when reset()
is called. Mark is not set by default. Mark is always no less
- * than zero and no greater than position
. */
- int mark = UNSET_MARK;
-
- /** The current position of this buffer. Position is always no less than zero and no greater than limit
. */
- int position = 0;
-
- /** Construct a buffer with the specified capacity.
- *
- * @param capacity the capacity of this buffer. */
- Buffer (int capacity) {
- super();
- if (capacity < 0) {
- throw new IllegalArgumentException();
- }
- this.capacity = this.limit = capacity;
- }
-
- /** Returns the capacity of this buffer.
- *
- * @return the number of elements that are contained in this buffer.
- * @since Android 1.0 */
- public final int capacity () {
- return capacity;
- }
-
- /** Clears this buffer.
- * - * While the content of this buffer is not changed, the following internal changes take place: the current position is reset - * back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is cleared. - *
- * - * @return this buffer. - * @since Android 1.0 */ - public final Buffer clear () { - position = 0; - mark = UNSET_MARK; - limit = capacity; - return this; - } - - /** Flips this buffer. - *- * The limit is set to the current position, then the position is set to zero, and the mark is cleared. - *
- *- * The content of this buffer is not changed. - *
- * - * @return this buffer. - * @since Android 1.0 */ - public final Buffer flip () { - limit = position; - position = 0; - mark = UNSET_MARK; - return this; - } - - /** Indicates if there are elements remaining in this buffer, that is if {@code position < limit}. - * - * @return {@code true} if there are elements remaining in this buffer, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasRemaining () { - return position < limit; - } - - /** Indicates whether this buffer is read-only. - * - * @return {@code true} if this buffer is read-only, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isReadOnly (); - - /** Returns the limit of this buffer. - * - * @return the limit of this buffer. - * @since Android 1.0 */ - public final int limit () { - return limit; - } - - /** Sets the limit of this buffer. - *
- * If the current position in the buffer is in excess of newLimit
then, on returning from this call, it will have
- * been adjusted to be equivalent to newLimit
. If the mark is set and is greater than the new limit, then it is
- * cleared.
- *
newLimit
is invalid.
- * @since Android 1.0 */
- public final Buffer limit (int newLimit) {
- if (newLimit < 0 || newLimit > capacity) {
- throw new IllegalArgumentException();
- }
-
- limit = newLimit;
- if (position > newLimit) {
- position = newLimit;
- }
- if ((mark != UNSET_MARK) && (mark > newLimit)) {
- mark = UNSET_MARK;
- }
- return this;
- }
-
- /** Marks the current position, so that the position may return to this point later by calling reset()
.
- *
- * @return this buffer.
- * @since Android 1.0 */
- public final Buffer mark () {
- mark = position;
- return this;
- }
-
- /** Returns the position of this buffer.
- *
- * @return the value of this buffer's current position.
- * @since Android 1.0 */
- public final int position () {
- return position;
- }
-
- /** Sets the position of this buffer.
- * - * If the mark is set and it is greater than the new position, then it is cleared. - *
- * - * @param newPosition the new position, must be not negative and not greater than limit. - * @return this buffer. - * @exception IllegalArgumentException ifnewPosition
is invalid.
- * @since Android 1.0 */
- public final Buffer position (int newPosition) {
- if (newPosition < 0 || newPosition > limit) {
- throw new IllegalArgumentException();
- }
-
- position = newPosition;
- if ((mark != UNSET_MARK) && (mark > position)) {
- mark = UNSET_MARK;
- }
- return this;
- }
-
- /** Returns the number of remaining elements in this buffer, that is {@code limit - position}.
- *
- * @return the number of remaining elements in this buffer.
- * @since Android 1.0 */
- public final int remaining () {
- return limit - position;
- }
-
- /** Resets the position of this buffer to the mark
.
- *
- * @return this buffer.
- * @exception InvalidMarkException if the mark is not set.
- * @since Android 1.0 */
- public final Buffer reset () {
- if (mark == UNSET_MARK) {
- throw new InvalidMarkException();
- }
- position = mark;
- return this;
- }
-
- /** Rewinds this buffer.
- * - * The position is set to zero, and the mark is cleared. The content of this buffer is not changed. - *
- * - * @return this buffer. - * @since Android 1.0 */ - public final Buffer rewind () { - position = 0; - mark = UNSET_MARK; - return this; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/BufferFactory.java b/backends/gdx-backend-dragome/emu/java/nio/BufferFactory.java deleted file mode 100644 index 8f58ee96..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/BufferFactory.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** Provide factory service of buffer classes. - *- * Since all buffer impl classes are package private (except DirectByteBuffer), this factory is the only entrance to access buffer - * functions from outside of the impl package. - *
*/ -final class BufferFactory { - - /** Returns a new byte buffer based on the specified byte array. - * - * @param array The byte array - * @return A new byte buffer based on the specified byte array. */ - public static ByteBuffer newByteBuffer (byte array[]) { - return new ReadWriteHeapByteBuffer(array); - } - - /** Returns a new array based byte buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based byte buffer with the specified capacity. */ - public static ByteBuffer newByteBuffer (int capacity) { - return new ReadWriteHeapByteBuffer(capacity); - } - - /** Returns a new char buffer based on the specified char array. - * - * @param array The char array - * @return A new char buffer based on the specified char array. */ - public static CharBuffer newCharBuffer (char array[]) { - return new ReadWriteCharArrayBuffer(array); - } - - /** Returns a new readonly char buffer based on the specified char sequence. - * - * @param chseq The char sequence - * @return A new readonly char buffer based on the specified char sequence. */ - public static CharBuffer newCharBuffer (CharSequence chseq) { - return new CharSequenceAdapter(chseq); - } - - /** Returns a new array based char buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based char buffer with the specified capacity. */ - public static CharBuffer newCharBuffer (int capacity) { - return new ReadWriteCharArrayBuffer(capacity); - } - - /** Returns a new direct byte buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new direct byte buffer with the specified capacity. */ - public static ByteBuffer newDirectByteBuffer (int capacity) { - return new DirectReadWriteByteBuffer(capacity); - } - - /** Returns a new double buffer based on the specified double array. - * - * @param array The double array - * @return A new double buffer based on the specified double array. */ - public static DoubleBuffer newDoubleBuffer (double array[]) { - return new ReadWriteDoubleArrayBuffer(array); - } - - /** Returns a new array based double buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based double buffer with the specified capacity. */ - public static DoubleBuffer newDoubleBuffer (int capacity) { - return new ReadWriteDoubleArrayBuffer(capacity); - } - - /** Returns a new float buffer based on the specified float array. - * - * @param array The float array - * @return A new float buffer based on the specified float array. */ - public static FloatBuffer newFloatBuffer (float array[]) { - return new ReadWriteFloatArrayBuffer(array); - } - - /** Returns a new array based float buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based float buffer with the specified capacity. */ - public static FloatBuffer newFloatBuffer (int capacity) { - return new ReadWriteFloatArrayBuffer(capacity); - } - - /** Returns a new array based int buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based int buffer with the specified capacity. */ - public static IntBuffer newIntBuffer (int capacity) { - return new ReadWriteIntArrayBuffer(capacity); - } - - /** Returns a new int buffer based on the specified int array. - * - * @param array The int array - * @return A new int buffer based on the specified int array. */ - public static IntBuffer newIntBuffer (int array[]) { - return new ReadWriteIntArrayBuffer(array); - } - - /** Returns a new array based long buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based long buffer with the specified capacity. */ - public static LongBuffer newLongBuffer (int capacity) { - return new ReadWriteLongArrayBuffer(capacity); - } - - /** Returns a new long buffer based on the specified long array. - * - * @param array The long array - * @return A new long buffer based on the specified long array. */ - public static LongBuffer newLongBuffer (long array[]) { - return new ReadWriteLongArrayBuffer(array); - } - - /** Returns a new array based short buffer with the specified capacity. - * - * @param capacity The capacity of the new buffer - * @return A new array based short buffer with the specified capacity. */ - public static ShortBuffer newShortBuffer (int capacity) { - return new ReadWriteShortArrayBuffer(capacity); - } - - /** Returns a new short buffer based on the specified short array. - * - * @param array The short array - * @return A new short buffer based on the specified short array. */ - public static ShortBuffer newShortBuffer (short array[]) { - return new ReadWriteShortArrayBuffer(array); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/BufferOverflowException.java b/backends/gdx-backend-dragome/emu/java/nio/BufferOverflowException.java deleted file mode 100644 index 923808ec..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/BufferOverflowException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** ABufferOverflowException
is thrown when elements are written to a buffer but there is not enough remaining space
- * in the buffer.
- *
- * @since Android 1.0 */
-public class BufferOverflowException extends RuntimeException {
-
- private static final long serialVersionUID = -5484897634319144535L;
-
- /** Constructs a BufferOverflowException
.
- *
- * @since Android 1.0 */
- public BufferOverflowException () {
- super();
- }
-}
diff --git a/backends/gdx-backend-dragome/emu/java/nio/BufferUnderflowException.java b/backends/gdx-backend-dragome/emu/java/nio/BufferUnderflowException.java
deleted file mode 100644
index 1d3251ee..00000000
--- a/backends/gdx-backend-dragome/emu/java/nio/BufferUnderflowException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.nio;
-
-/** A BufferUnderflowException
is thrown when elements are read from a buffer but there are not enough remaining
- * elements in the buffer.
- *
- * @since Android 1.0 */
-public class BufferUnderflowException extends RuntimeException {
-
- private static final long serialVersionUID = -1713313658691622206L;
-
- /** Constructs a BufferUnderflowException
.
- *
- * @since Android 1.0 */
- public BufferUnderflowException () {
- super();
- }
-}
diff --git a/backends/gdx-backend-dragome/emu/java/nio/ByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ByteBuffer.java
deleted file mode 100644
index 2c0d7ad0..00000000
--- a/backends/gdx-backend-dragome/emu/java/nio/ByteBuffer.java
+++ /dev/null
@@ -1,836 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package java.nio;
-
-import com.badlogic.gdx.backends.dragome.utils.Endianness;
-import com.badlogic.gdx.backends.dragome.utils.StringToByteBuffer;
-
-/** A buffer for bytes.
- * - * A byte buffer can be created in either one of the following ways: - *
- *- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *
- * - * @param array the byte array which the new buffer will be based on - * @return the created byte buffer. - * @since Android 1.0 */ - public static ByteBuffer wrap (byte[] array) { - return BufferFactory.newByteBuffer(array); - } - - /** Creates a new byte buffer by wrapping the given byte array. - *- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *
- * - * @param array the byte array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created byte buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static ByteBuffer wrap (byte[] array, int start, int len) { - int length = array.length; - if ((start < 0) || (len < 0) || ((long)start + (long)len > length)) { - throw new IndexOutOfBoundsException(); - } - - ByteBuffer buf = BufferFactory.newByteBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** The byte order of this buffer, default is {@code BIG_ENDIAN}. */ - Endianness order = Endianness.BIG_ENDIAN; - - /** Constructs a {@code ByteBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. */ - ByteBuffer (int capacity) { - super(capacity); - } - - /** Returns the byte array which this buffer is based on, if there is one. - * - * @return the byte array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on a read-only array. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final byte[] array () { - return protectedArray(); - } - - /** Returns the offset of the byte array which this buffer is based on, if there is one. - *- * The offset is the index of the array which corresponds to the zero position of the buffer. - *
- * - * @return the offset of the byte array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on a read-only array. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a char buffer which is based on the remaining content of this byte buffer. - *- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a char buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract CharBuffer asCharBuffer (); - - /** Returns a double buffer which is based on the remaining content of this byte buffer. - *- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a double buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer asDoubleBuffer (); - - /** Returns a float buffer which is based on the remaining content of this byte buffer. - *- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by four, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a float buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract FloatBuffer asFloatBuffer (); - - /** Returns a int buffer which is based on the remaining content of this byte buffer. - *- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by four, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a int buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract IntBuffer asIntBuffer (); - - /** Returns a long buffer which is based on the remaining content of this byte buffer. - *- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a long buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract LongBuffer asLongBuffer (); - - /** Returns a read-only buffer that shares its content with this buffer. - *- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer. - *
- *- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *
- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer asReadOnlyBuffer (); - - /** Returns a short buffer which is based on the remaining content of this byte buffer. - *- * The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by two, and its mark is - * not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this - * byte buffer is direct. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a short buffer which is based on the content of this byte buffer. - * @since Android 1.0 */ - public abstract ShortBuffer asShortBuffer (); - - /** Compacts this byte buffer. - *- * The remaining bytes will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *
- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer compact (); - - /** Compares the remaining bytes of this buffer to another byte buffer's remaining bytes. - * - * @param otherBuffer another byte buffer. - * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is - * greater than {@code other}. - * @exception ClassCastException if {@code other} is not a byte buffer. - * @since Android 1.0 */ - public int compareTo (ByteBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - byte thisByte, otherByte; - while (compareRemaining > 0) { - thisByte = get(thisPos); - otherByte = otherBuffer.get(otherPos); - if (thisByte != otherByte) { - return thisByte < otherByte ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only - * property and byte order are the same as this buffer's too. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer duplicate (); - - /** Checks whether this byte buffer is equal to another object. - *- * If {@code other} is not a byte buffer then {@code false} is returned. Two byte buffers are equal if and only if their - * remaining bytes are exactly the same. Position, limit, capacity and mark are not considered. - *
- * - * @param other the object to compare with this byte buffer. - * @return {@code true} if this byte buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof ByteBuffer)) { - return false; - } - ByteBuffer otherBuffer = (ByteBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the byte at the current position and increases the position by 1. - * - * @return the byte at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract byte get (); - - /** Reads bytes from the current position into the specified byte array and increases the position by the number of bytes read. - *- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *
- * - * @param dest the destination byte array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ByteBuffer get (byte[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads bytes from the current position into the specified byte array, starting at the specified offset, and increases the - * position by the number of bytes read. - * - * @param dest the target byte array. - * @param off the offset of the byte array, must not be negative and not greater than {@code dest.length}. - * @param len the number of bytes to read, must not be negative and not greater than {@code dest.length - off} - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ByteBuffer get (byte[] dest, int off, int len) { - int length = dest.length; - if ((off < 0) || (len < 0) || ((long)off + (long)len > length)) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns the byte at the specified index and does not change the position. - * - * @param index the index, must not be negative and less than limit. - * @return the byte at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract byte get (int index); - - /** Returns the char at the current position and increases the position by 2. - *- * The 2 bytes starting at the current position are composed into a char according to the current byte order and returned. - *
- * - * @return the char at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 2}. - * @since Android 1.0 */ - public abstract char getChar (); - - /** Returns the char at the specified index. - *- * The 2 bytes starting from the specified index are composed into a char according to the current byte order and returned. The - * position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @return the char at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract char getChar (int index); - - /** Returns the double at the current position and increases the position by 8. - *- * The 8 bytes starting from the current position are composed into a double according to the current byte order and returned. - *
- * - * @return the double at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 8}. - * @since Android 1.0 */ - public abstract double getDouble (); - - /** Returns the double at the specified index. - *- * The 8 bytes starting at the specified index are composed into a double according to the current byte order and returned. The - * position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @return the double at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract double getDouble (int index); - - /** Returns the float at the current position and increases the position by 4. - *- * The 4 bytes starting at the current position are composed into a float according to the current byte order and returned. - *
- * - * @return the float at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 4}. - * @since Android 1.0 */ - public abstract float getFloat (); - - /** Returns the float at the specified index. - *- * The 4 bytes starting at the specified index are composed into a float according to the current byte order and returned. The - * position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @return the float at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract float getFloat (int index); - - /** Returns the int at the current position and increases the position by 4. - *- * The 4 bytes starting at the current position are composed into a int according to the current byte order and returned. - *
- * - * @return the int at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 4}. - * @since Android 1.0 */ - public abstract int getInt (); - - /** Returns the int at the specified index. - *- * The 4 bytes starting at the specified index are composed into a int according to the current byte order and returned. The - * position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @return the int at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract int getInt (int index); - - /** Returns the long at the current position and increases the position by 8. - *- * The 8 bytes starting at the current position are composed into a long according to the current byte order and returned. - *
- * - * @return the long at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 8}. - * @since Android 1.0 */ - public abstract long getLong (); - - /** Returns the long at the specified index. - *- * The 8 bytes starting at the specified index are composed into a long according to the current byte order and returned. The - * position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @return the long at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract long getLong (int index); - - /** Returns the short at the current position and increases the position by 2. - *- * The 2 bytes starting at the current position are composed into a short according to the current byte order and returned. - *
- * - * @return the short at the current position. - * @exception BufferUnderflowException if the position is greater than {@code limit - 2}. - * @since Android 1.0 */ - public abstract short getShort (); - - /** Returns the short at the specified index. - *- * The 2 bytes starting at the specified index are composed into a short according to the current byte order and returned. The - * position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @return the short at the specified index. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @since Android 1.0 */ - public abstract short getShort (int index); - - /** Indicates whether this buffer is based on a byte array and provides read/write access. - * - * @return {@code true} if this buffer is based on a byte array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining bytes. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. - * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting bytes from/to other primitive types. - *- * The default byte order of byte buffer is always {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} - *
- * - * @return the byte order used by this buffer when converting bytes from/to other primitive types. - * @since Android 1.0 */ - public final ByteOrder order () { - return order == Endianness.BIG_ENDIAN ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; - } - - /** Sets the byte order of this buffer. - * - * @param byteOrder the byte order to set. If {@code null} then the order will be {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN} - * . - * @return this buffer. - * @see ByteOrder - * @since Android 1.0 */ - public final ByteBuffer order (ByteOrder byteOrder) { - return orderImpl(byteOrder); - } - - ByteBuffer orderImpl (ByteOrder byteOrder) { - order = byteOrder == ByteOrder.BIG_ENDIAN ? Endianness.BIG_ENDIAN : Endianness.LITTLE_ENDIAN; - return this; - } - - /** Child class implements this method to realize {@code array()}. - * - * @see #array() - * @since Android 1.0 */ - abstract byte[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @see #arrayOffset() - * @since Android 1.0 */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @see #hasArray() - * @since Android 1.0 */ - abstract boolean protectedHasArray (); - - /** Writes the given byte to the current position and increases the position by 1. - * - * @param b the byte to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer put (byte b); - - /** Writes bytes in the given byte array to the current position and increases the position by the number of bytes written. - *- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *
- * - * @param src the source byte array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final ByteBuffer put (byte[] src) { - return put(src, 0, src.length); - } - - /** Writes bytes in the given byte array, starting from the specified offset, to the current position and increases the position - * by the number of bytes written. - * - * @param src the source byte array. - * @param off the offset of byte array, must not be negative and not greater than {@code src.length}. - * @param len the number of bytes to write, must not be negative and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ByteBuffer put (byte[] src, int off, int len) { - int length = src.length; - if ((off < 0) || (len < 0) || ((long)off + (long)len > length)) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining bytes of the {@code src} byte buffer to this buffer's current position, and increases both buffers' - * position by the number of bytes copied. - * - * @param src the source byte buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ByteBuffer put (ByteBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - byte[] contents = new byte[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Write a byte to the specified index of this buffer without changing the position. - * - * @param index the index, must not be negative and less than the limit. - * @param b the byte to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer put (int index, byte b); - - /** Writes the given char to the current position and increases the position by 2. - *- * The char is converted to bytes using the current byte order. - *
- * - * @param value the char to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 2}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putChar (char value); - - /** Writes the given char to the specified index of this buffer. - *- * The char is converted to bytes using the current byte order. The position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @param value the char to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putChar (int index, char value); - - /** Writes the given double to the current position and increases the position by 8. - *- * The double is converted to bytes using the current byte order. - *
- * - * @param value the double to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 8}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putDouble (double value); - - /** Writes the given double to the specified index of this buffer. - *- * The double is converted to bytes using the current byte order. The position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @param value the double to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putDouble (int index, double value); - - /** Writes the given float to the current position and increases the position by 4. - *- * The float is converted to bytes using the current byte order. - *
- * - * @param value the float to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 4}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putFloat (float value); - - /** Writes the given float to the specified index of this buffer. - *- * The float is converted to bytes using the current byte order. The position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @param value the float to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putFloat (int index, float value); - - /** Writes the given int to the current position and increases the position by 4. - *- * The int is converted to bytes using the current byte order. - *
- * - * @param value the int to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 4}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putInt (int value); - - /** Writes the given int to the specified index of this buffer. - *- * The int is converted to bytes using the current byte order. The position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 4}. - * @param value the int to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putInt (int index, int value); - - /** Writes the given long to the current position and increases the position by 8. - *- * The long is converted to bytes using the current byte order. - *
- * - * @param value the long to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 8}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putLong (long value); - - /** Writes the given long to the specified index of this buffer. - *- * The long is converted to bytes using the current byte order. The position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 8}. - * @param value the long to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putLong (int index, long value); - - /** Writes the given short to the current position and increases the position by 2. - *- * The short is converted to bytes using the current byte order. - *
- * - * @param value the short to write. - * @return this buffer. - * @exception BufferOverflowException if position is greater than {@code limit - 2}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putShort (short value); - - /** Writes the given short to the specified index of this buffer. - *- * The short is converted to bytes using the current byte order. The position is not changed. - *
- * - * @param index the index, must not be negative and equal or less than {@code limit - 2}. - * @param value the short to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if {@code index} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer putShort (int index, short value); - - /** Returns a sliced buffer that shares its content with this buffer. - *- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and it's zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ByteBuffer slice (); - - /** Returns a string representing the state of this byte buffer. - * - * @return a string representing the state of this byte buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } - - public ByteBuffer stringToByteBuffer (String s) { - return new StringByteBuffer(s); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ByteBufferWrapper.java b/backends/gdx-backend-dragome/emu/java/nio/ByteBufferWrapper.java deleted file mode 100644 index a8654af4..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ByteBufferWrapper.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package java.nio; - -public interface ByteBufferWrapper { - ByteBuffer getByteBuffer (); -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ByteOrder.java b/backends/gdx-backend-dragome/emu/java/nio/ByteOrder.java deleted file mode 100644 index a5b0f470..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ByteOrder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.luni.platform.Platform; - -/** Defines byte order constants. - * - * @since Android 1.0 */ -public final class ByteOrder { - - /** This constant represents big endian. - * - * @since Android 1.0 */ - public static final ByteOrder BIG_ENDIAN = new ByteOrder("BIG_ENDIAN"); //$NON-NLS-1$ - - /** This constant represents little endian. - * - * @since Android 1.0 */ - public static final ByteOrder LITTLE_ENDIAN = new ByteOrder("LITTLE_ENDIAN"); //$NON-NLS-1$ - - private static final ByteOrder NATIVE_ORDER; - - static { -// if (Platform.getMemorySystem().isLittleEndian()) { - NATIVE_ORDER = LITTLE_ENDIAN; -// } else { -// NATIVE_ORDER = BIG_ENDIAN; -// } - } - - /** Returns the current platform byte order. - * - * @return the byte order object, which is either LITTLE_ENDIAN or BIG_ENDIAN. - * @since Android 1.0 */ - public static ByteOrder nativeOrder () { - return NATIVE_ORDER; - } - - private final String name; - - private ByteOrder (String name) { - super(); - this.name = name; - } - - /** Returns a string that describes this object. - * - * @return "BIG_ENDIAN" for {@link #BIG_ENDIAN ByteOrder.BIG_ENDIAN} objects, "LITTLE_ENDIAN" for {@link #LITTLE_ENDIAN - * ByteOrder.LITTLE_ENDIAN} objects. - * @since Android 1.0 */ - public String toString () { - return name; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/CharArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/CharArrayBuffer.java deleted file mode 100644 index 17a0522b..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/CharArrayBuffer.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** CharArrayBuffer, ReadWriteCharArrayBuffer and ReadOnlyCharArrayBuffer compose the implementation of array based char buffers. - *- * CharArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class CharArrayBuffer extends CharBuffer { - - protected final char[] backingArray; - - protected final int offset; - - CharArrayBuffer (char[] array) { - this(array.length, array, 0); - } - - CharArrayBuffer (int capacity) { - this(capacity, new char[capacity], 0); - } - - CharArrayBuffer (int capacity, char[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final char get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final char get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final CharBuffer get (char[] dest, int off, int len) { - int length = dest.length; - if ((off < 0) || (len < 0) || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - - public final CharSequence subSequence (int start, int end) { - if (start < 0 || end < start || end > remaining()) { - throw new IndexOutOfBoundsException(); - } - - CharBuffer result = duplicate(); - result.limit(position + end); - result.position(position + start); - return result; - } - - public final String toString () { - return String.copyValueOf(backingArray, offset + position, remaining()); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/CharBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/CharBuffer.java deleted file mode 100644 index 8011e36f..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/CharBuffer.java +++ /dev/null @@ -1,622 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import java.io.IOException; - -/** A buffer of chars. - *- * A char buffer can be created in either one of the following ways: - *
- *- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *
- * - * @param array the char array which the new buffer will be based on. - * @return the created char buffer. - * @since Android 1.0 */ - public static CharBuffer wrap (char[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new char buffer by wrapping the given char array. - *- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *
- * - * @param array the char array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created char buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static CharBuffer wrap (char[] array, int start, int len) { - int length = array.length; - if ((start < 0) || (len < 0) || (long)start + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - CharBuffer buf = BufferFactory.newCharBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Creates a new char buffer by wrapping the given char sequence. - *- * Calling this method has the same effect as {@code wrap(chseq, 0, chseq.length())}. - *
- * - * @param chseq the char sequence which the new buffer will be based on. - * @return the created char buffer. - * @since Android 1.0 */ - public static CharBuffer wrap (CharSequence chseq) { - return BufferFactory.newCharBuffer(chseq); - } - - /** Creates a new char buffer by wrapping the given char sequence. - *- * The new buffer's position will be {@code start}, limit will be {@code end}, capacity will be the length of the char sequence. - * The new buffer is read-only. - *
- * - * @param chseq the char sequence which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code chseq.length()}. - * @param end the end index, must be no less than {@code start} and no greater than {@code chseq.length()}. - * @return the created char buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @since Android 1.0 */ - public static CharBuffer wrap (CharSequence chseq, int start, int end) { - if (chseq == null) { - throw new NullPointerException(); - } - if (start < 0 || end < start || end > chseq.length()) { - throw new IndexOutOfBoundsException(); - } - - CharBuffer result = BufferFactory.newCharBuffer(chseq); - result.position = start; - result.limit = end; - return result; - } - - /** Constructs a {@code CharBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. - * @since Android 1.0 */ - CharBuffer (int capacity) { - super(capacity); - } - - /** Returns the char array which this buffer is based on, if there is one. - * - * @return the char array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final char[] array () { - return protectedArray(); - } - - /** Returns the offset of the char array which this buffer is based on, if there is one. - *- * The offset is the index of the array corresponds to the zero position of the buffer. - *
- * - * @return the offset of the char array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *
- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer asReadOnlyBuffer (); - - /** Returns the character located at the specified index in the buffer. The index value is referenced from the current buffer - * position. - * - * @param index the index referenced from the current buffer position. It must not be less than zero but less than the value - * obtained from a call to {@code remaining()}. - * @return the character located at the specified index (referenced from the current position) in the buffer. - * @exception IndexOutOfBoundsException if the index is invalid. - * @since Android 1.0 */ - public final char charAt (int index) { - if (index < 0 || index >= remaining()) { - throw new IndexOutOfBoundsException(); - } - return get(position + index); - } - - /** Compacts this char buffer. - *- * The remaining chars will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *
- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer compact (); - - /** Compare the remaining chars of this buffer to another char buffer's remaining chars. - * - * @param otherBuffer another char buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer}. - * @exception ClassCastException if {@code otherBuffer} is not a char buffer. - * @since Android 1.0 */ - public int compareTo (CharBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - char thisByte, otherByte; - while (compareRemaining > 0) { - thisByte = get(thisPos); - otherByte = otherBuffer.get(otherPos); - if (thisByte != otherByte) { - return thisByte < otherByte ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *- * The duplicated buffer's initial position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's - * read-only property and byte order are the same as this buffer's, too. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract CharBuffer duplicate (); - - /** Checks whether this char buffer is equal to another object. - *- * If {@code other} is not a char buffer then {@code false} is returned. Two char buffers are equal if and only if their - * remaining chars are exactly the same. Position, limit, capacity and mark are not considered. - *
- * - * @param other the object to compare with this char buffer. - * @return {@code true} if this char buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof CharBuffer)) { - return false; - } - CharBuffer otherBuffer = (CharBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the char at the current position and increases the position by 1. - * - * @return the char at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract char get (); - - /** Reads chars from the current position into the specified char array and increases the position by the number of chars read. - *- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *
- * - * @param dest the destination char array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public CharBuffer get (char[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads chars from the current position into the specified char array, starting from the specified offset, and increases the - * position by the number of chars read. - * - * @param dest the target char array. - * @param off the offset of the char array, must not be negative and not greater than {@code dest.length}. - * @param len The number of chars to read, must be no less than zero and no greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public CharBuffer get (char[] dest, int off, int len) { - int length = dest.length; - if ((off < 0) || (len < 0) || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns a char at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a char at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract char get (int index); - - /** Indicates whether this buffer is based on a char array and is read/write. - * - * @return {@code true} if this buffer is based on a byte array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining chars. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *- * A char buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the number of remaining chars. - * - * @return the number of remaining chars. - * @since Android 1.0 */ - public final int length () { - return remaining(); - } - - /** Returns the byte order used by this buffer when converting chars from/to bytes. - *- * If this buffer is not based on a byte buffer, then this always returns the platform's native byte order. - *
- * - * @return the byte order used by this buffer when converting chars from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @see #array() */ - abstract char[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @see #arrayOffset() */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @see #hasArray() */ - abstract boolean protectedHasArray (); - - /** Writes the given char to the current position and increases the position by 1. - * - * @param c the char to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer put (char c); - - /** Writes chars from the given char array to the current position and increases the position by the number of chars written. - *- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *
- * - * @param src the source char array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final CharBuffer put (char[] src) { - return put(src, 0, src.length); - } - - /** Writes chars from the given char array, starting from the specified offset, to the current position and increases the - * position by the number of chars written. - * - * @param src the source char array. - * @param off the offset of char array, must not be negative and not greater than {@code src.length}. - * @param len the number of chars to write, must be no less than zero and no greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer put (char[] src, int off, int len) { - int length = src.length; - if ((off < 0) || (len < 0) || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining chars of the {@code src} char buffer to this buffer's current position, and increases both buffers' - * position by the number of chars copied. - * - * @param src the source char buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer put (CharBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - - char[] contents = new char[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a char to the specified index of this buffer; the position is not changed. - * - * @param index the index, must be no less than zero and less than the limit. - * @param c the char to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract CharBuffer put (int index, char c); - - /** Writes all chars of the given string to the current position of this buffer, and increases the position by the length of - * string. - *- * Calling this method has the same effect as {@code put(str, 0, str.length())}. - *
- * - * @param str the string to write. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than the length of string. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final CharBuffer put (String str) { - return put(str, 0, str.length()); - } - - /** Writes chars of the given string to the current position of this buffer, and increases the position by the number of chars - * written. - * - * @param str the string to write. - * @param start the first char to write, must not be negative and not greater than {@code str.length()}. - * @param end the last char to write (excluding), must be less than {@code start} and not greater than {@code str.length()}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code end - start}. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer put (String str, int start, int end) { - int length = str.length(); - if (start < 0 || end < start || end > length) { - throw new IndexOutOfBoundsException(); - } - - if (end - start > remaining()) { - throw new BufferOverflowException(); - } - for (int i = start; i < end; i++) { - put(str.charAt(i)); - } - return this; - } - - /** Returns a sliced buffer that shares its content with this buffer. - *- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract CharBuffer slice (); - - /** Returns a new char buffer representing a sub-sequence of this buffer's current remaining content. - *- * The new buffer's position will be {@code position() + start}, limit will be {@code position() + end}, capacity will be the - * same as this buffer. The new buffer's read-only property and byte order are the same as this buffer. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @param start the start index of the sub-sequence, referenced from the current buffer position. Must not be less than zero - * and not greater than the value obtained from a call to {@code remaining()}. - * @param end the end index of the sub-sequence, referenced from the current buffer position. Must not be less than - * {@code start} and not be greater than the value obtained from a call to {@code remaining()}. - * @return a new char buffer represents a sub-sequence of this buffer's current remaining content. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @since Android 1.0 */ - public abstract CharSequence subSequence (int start, int end); - - /** Returns a string representing the current remaining chars of this buffer. - * - * @return a string representing the current remaining chars of this buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer strbuf = new StringBuffer(); - for (int i = position; i < limit; i++) { - strbuf.append(get(i)); - } - return strbuf.toString(); - } - - /** Writes the given char to the current position and increases the position by 1. - * - * @param c the char to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer append (char c) { - return put(c); - } - - /** Writes all chars of the given character sequence {@code csq} to the current position of this buffer, and increases the - * position by the length of the csq. - *- * Calling this method has the same effect as {@code append(csq.toString())}. - *
- * If the {@code CharSequence} is {@code null} the string "null" will be written to the buffer. - * - * @param csq the {@code CharSequence} to write. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than the length of csq. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer append (CharSequence csq) { - if (csq != null) { - return put(csq.toString()); - } - return put("null"); //$NON-NLS-1$ - } - - /** Writes chars of the given {@code CharSequence} to the current position of this buffer, and increases the position by the - * number of chars written. - * - * @param csq the {@code CharSequence} to write. - * @param start the first char to write, must not be negative and not greater than {@code csq.length()}. - * @param end the last char to write (excluding), must be less than {@code start} and not greater than {@code csq.length()}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code end - start}. - * @exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public CharBuffer append (CharSequence csq, int start, int end) { - if (csq == null) { - csq = "null"; //$NON-NLS-1$ - } - CharSequence cs = csq.subSequence(start, end); - if (cs.length() > 0) { - return put(cs.toString()); - } - return this; - } - - /** Reads characters from this buffer and puts them into {@code target}. The number of chars that are copied is either the - * number of remaining chars in this buffer or the number of remaining chars in {@code target}, whichever is smaller. - * - * @param target the target char buffer. - * @throws IllegalArgumentException if {@code target} is this buffer. - * @throws IOException if an I/O error occurs. - * @throws ReadOnlyBufferException if no changes may be made to the contents of {@code target}. - * @return the number of chars copied or -1 if there are no chars left to be read from this buffer. - * @since Android 1.0 */ - public int read (CharBuffer target) throws IOException { - if (target == this) { - throw new IllegalArgumentException(); - } - if (remaining() == 0) { - return target.remaining() == 0 ? 0 : -1; - } - int result = Math.min(target.remaining(), remaining()); - char[] chars = new char[result]; - get(chars); - target.put(chars); - return result; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/CharSequenceAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/CharSequenceAdapter.java deleted file mode 100644 index 45b7e77e..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/CharSequenceAdapter.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** This class wraps a char sequence to be a char buffer. - *- * Implementation notice: - *
- * Implementation notice: - *
- * DirectByteBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class DirectByteBuffer extends BaseByteBuffer implements HasArrayBufferView { - - Int8Array byteArray; - - DirectByteBuffer (int capacity) { - this(ArrayBuffer.create(capacity), capacity, 0); - } - - DirectByteBuffer (ArrayBuffer buf) { - this(buf, buf.get_byteLength(), 0); - } - - DirectByteBuffer (ArrayBuffer buffer, int capacity, int offset) { - super(capacity); - byteArray = Int8Array.create(buffer, offset, capacity); - } - - public ArrayBufferView getTypedArray () { - return byteArray; - } - - public int getElementSize () { - return 1; - } - - /* - * Override ByteBuffer.get(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#get(byte[], int, int) - */ - public final ByteBuffer get (byte[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - - for (int i = 0; i < len; i++) { - dest[i + off] = get(position + i); - } - - position += len; - return this; - } - - public final byte get () { -// if (position == limit) { -// throw new BufferUnderflowException(); -// } - return (byte)byteArray.get(position++); - } - - public final byte get (int index) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - return (byte)byteArray.get(index); - } - - public final double getDouble () { - return Numbers.longBitsToDouble(getLong()); - } - - public final double getDouble (int index) { - return Numbers.longBitsToDouble(getLong(index)); - } - - public final float getFloat () { - return Numbers.intBitsToFloat(getInt()); - } - - public final float getFloat (int index) { - return Numbers.intBitsToFloat(getInt(index)); - } - - public final int getInt () { - int newPosition = position + 4; -// if (newPosition > limit) { -// throw new BufferUnderflowException(); -// } - int result = loadInt(position); - position = newPosition; - return result; - } - - public final int getInt (int index) { -// if (index < 0 || index + 4 > limit) { -// throw new IndexOutOfBoundsException(); -// } - return loadInt(index); - } - - public final long getLong () { - int newPosition = position + 8; -// if (newPosition > limit) { -// throw new BufferUnderflowException(); -// } - long result = loadLong(position); - position = newPosition; - return result; - } - - public final long getLong (int index) { -// if (index < 0 || index + 8 > limit) { -// throw new IndexOutOfBoundsException(); -// } - return loadLong(index); - } - - public final short getShort () { - int newPosition = position + 2; -// if (newPosition > limit) { -// throw new BufferUnderflowException(); -// } - short result = loadShort(position); - position = newPosition; - return result; - } - - public final short getShort (int index) { -// if (index < 0 || index + 2 > limit) { -// throw new IndexOutOfBoundsException(); -// } - return loadShort(index); - } - - public final boolean isDirect () { - return false; - } - - protected final int loadInt (int baseOffset) { - int bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 4; i++) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } else { - for (int i = 3; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } - return bytes; - } - - protected final long loadLong (int baseOffset) { - long bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 8; i++) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } else { - for (int i = 7; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (byteArray.get(baseOffset + i) & 0xFF); - } - } - return bytes; - } - - protected final short loadShort (int baseOffset) { - short bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - bytes = (short)(byteArray.get(baseOffset) << 8); - bytes |= (byteArray.get(baseOffset + 1) & 0xFF); - } else { - bytes = (short)(byteArray.get(baseOffset + 1) << 8); - bytes |= (byteArray.get(baseOffset) & 0xFF); - } - return bytes; - } - - protected final void store (int baseOffset, int value) { - if (order == Endianness.BIG_ENDIAN) { - for (int i = 3; i >= 0; i--) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } else { - for (int i = 0; i <= 3; i++) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } - } - - protected final void store (int baseOffset, long value) { - if (order == Endianness.BIG_ENDIAN) { - for (int i = 7; i >= 0; i--) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } else { - for (int i = 0; i <= 7; i++) { - byteArray.set(baseOffset + i, (byte)(value & 0xFF)); - value = value >> 8; - } - } - } - - protected final void store (int baseOffset, short value) { - if (order == Endianness.BIG_ENDIAN) { - byteArray.set(baseOffset, (byte)((value >> 8) & 0xFF)); - byteArray.set(baseOffset + 1, (byte)(value & 0xFF)); - } else { - byteArray.set(baseOffset + 1, (byte)((value >> 8) & 0xFF)); - byteArray.set(baseOffset, (byte)(value & 0xFF)); - } - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyByteBuffer.java deleted file mode 100644 index 156b9225..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyByteBuffer.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBuffer; - -/** HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers. - *- * ReadOnlyHeapByteBuffer extends HeapByteBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class DirectReadOnlyByteBuffer extends DirectByteBuffer { - - static DirectReadOnlyByteBuffer copy (DirectByteBuffer other, int markOfOther) { - DirectReadOnlyByteBuffer buf = new DirectReadOnlyByteBuffer(other.byteArray.get_buffer(), other.capacity(), - other.byteArray.get_byteOffset()); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - DirectReadOnlyByteBuffer (ArrayBuffer backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public ByteBuffer asReadOnlyBuffer () { - return copy(this, mark); - } - - public ByteBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected byte[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public FloatBuffer asFloatBuffer () { - return DirectReadOnlyFloatBufferAdapter.wrap(this); - } - - public IntBuffer asIntBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadOnlyIntBufferAdapter.wrap(this) : super.asIntBuffer(); - } - - public ShortBuffer asShortBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadOnlyShortBufferAdapter.wrap(this) : super.asShortBuffer(); - } - - public ByteBuffer put (byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (int index, byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (byte[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (int index, double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (int index, float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int index, int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (int index, long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (int index, short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (ByteBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer slice () { - DirectReadOnlyByteBuffer slice = new DirectReadOnlyByteBuffer(byteArray.get_buffer(), remaining(), byteArray.get_byteOffset() - + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyFloatBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyFloatBufferAdapter.java deleted file mode 100644 index 07dd47d6..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadOnlyFloatBufferAdapter.java +++ /dev/null @@ -1,145 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a float buffer. - *- * Implementation notice: - *
- * Implementation notice: - *
- * Implementation notice: - *
- * DirectReadWriteByteBuffer extends DirectByteBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -public final class DirectReadWriteByteBuffer extends DirectByteBuffer { - - static DirectReadWriteByteBuffer copy (DirectByteBuffer other, int markOfOther) { - DirectReadWriteByteBuffer buf = new DirectReadWriteByteBuffer(other.byteArray.get_buffer(), other.capacity(), - other.byteArray.get_byteOffset()); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - DirectReadWriteByteBuffer (ArrayBuffer backingArray) { - super(backingArray); - } - - public DirectReadWriteByteBuffer (int capacity) { - super(capacity); - } - - DirectReadWriteByteBuffer (ArrayBuffer backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public FloatBuffer asFloatBuffer () { - return DirectReadWriteFloatBufferAdapter.wrap(this); - } - - public IntBuffer asIntBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadWriteIntBufferAdapter.wrap(this) : super.asIntBuffer(); - } - - public ShortBuffer asShortBuffer () { - return order() == ByteOrder.nativeOrder() ? DirectReadWriteShortBufferAdapter.wrap(this) : super.asShortBuffer(); - } - - public ByteBuffer asReadOnlyBuffer () { - return DirectReadOnlyByteBuffer.copy(this, mark); - } - - public ByteBuffer compact () { -// System.arraycopy(backingArray, position + offset, backingArray, offset, -// remaining()); - - int rem = remaining(); - for (int i = 0; i < rem; i++) { - byteArray.set(i, byteArray.get(position + i)); - } - - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected byte[] protectedArray () { - throw new UnsupportedOperationException(); - } - - protected int protectedArrayOffset () { - throw new UnsupportedOperationException(); - } - - protected boolean protectedHasArray () { - return true; - } - - public ByteBuffer put (byte b) { -// if (position == limit) { -// throw new BufferOverflowException(); -// } - byteArray.set(position++, b); - return this; - } - - public ByteBuffer put (int index, byte b) { -// if (index < 0 || index >= limit) { -// throw new IndexOutOfBoundsException(); -// } - byteArray.set(index, b); - return this; - } - - /* - * Override ByteBuffer.put(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#put(byte[], int, int) - */ - public ByteBuffer put (byte[] src, int off, int len) { - if (off < 0 || len < 0 || (long)off + (long)len > src.length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - if (isReadOnly()) { - throw new ReadOnlyBufferException(); - } - for (int i = 0; i < len; i++) { - byteArray.set(i + position, src[off + i]); - } - position += len; - return this; - } - - public ByteBuffer putDouble (double value) { - return putLong(Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putDouble (int index, double value) { - return putLong(index, Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putFloat (float value) { - return putInt(Numbers.floatToIntBits(value)); - } - - public ByteBuffer putFloat (int index, float value) { - return putInt(index, Numbers.floatToIntBits(value)); - } - - public ByteBuffer putInt (int value) { - int newPosition = position + 4; -// if (newPosition > limit) { -// throw new BufferOverflowException(); -// } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putInt (int index, int value) { -// if (index < 0 || (long)index + 4 > limit) { -// throw new IndexOutOfBoundsException(); -// } - store(index, value); - return this; - } - - public ByteBuffer putLong (int index, long value) { -// if (index < 0 || (long)index + 8 > limit) { -// throw new IndexOutOfBoundsException(); -// } - store(index, value); - return this; - } - - public ByteBuffer putLong (long value) { - int newPosition = position + 8; -// if (newPosition > limit) { -// throw new BufferOverflowException(); -// } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putShort (int index, short value) { -// if (index < 0 || (long)index + 2 > limit) { -// throw new IndexOutOfBoundsException(); -// } - store(index, value); - return this; - } - - public ByteBuffer putShort (short value) { - int newPosition = position + 2; -// if (newPosition > limit) { -// throw new BufferOverflowException(); -// } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer slice () { - DirectReadWriteByteBuffer slice = new DirectReadWriteByteBuffer(byteArray.get_buffer(), remaining(), - byteArray.get_byteOffset() + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteFloatBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteFloatBufferAdapter.java deleted file mode 100644 index 1bed4d61..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DirectReadWriteFloatBufferAdapter.java +++ /dev/null @@ -1,162 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import com.badlogic.gdx.backends.dragome.js.typedarrays.ArrayBufferView; -import com.badlogic.gdx.backends.dragome.js.typedarrays.Float32Array; -import com.badlogic.gdx.backends.dragome.js.typedarrays.utils.TypedArrays; - -/** This class wraps a byte buffer to be a float buffer. - *- * Implementation notice: - *
- * Implementation notice: - *
- * Implementation notice: - *
- * DoubleArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class DoubleArrayBuffer extends DoubleBuffer { - - protected final double[] backingArray; - - protected final int offset; - - DoubleArrayBuffer (double[] array) { - this(array.length, array, 0); - } - - DoubleArrayBuffer (int capacity) { - this(capacity, new double[capacity], 0); - } - - DoubleArrayBuffer (int capacity, double[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final double get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final double get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final DoubleBuffer get (double[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DoubleBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/DoubleBuffer.java deleted file mode 100644 index c88d69c6..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DoubleBuffer.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of doubles. - *- * A double buffer can be created in either one of the following ways: - *
- *- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *
- * - * @param array the double array which the new buffer will be based on. - * @return the created double buffer. - * @since Android 1.0 */ - public static DoubleBuffer wrap (double[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new double buffer by wrapping the given double array. - *- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *
- * - * @param array the double array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created double buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static DoubleBuffer wrap (double[] array, int start, int len) { - int length = array.length; - if (start < 0 || len < 0 || (long)start + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - DoubleBuffer buf = BufferFactory.newDoubleBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code DoubleBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. */ - DoubleBuffer (int capacity) { - super(capacity); - } - - /** Returns the double array which this buffer is based on, if there is one. - * - * @return the double array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final double[] array () { - return protectedArray(); - } - - /** Returns the offset of the double array which this buffer is based on, if there is one. - *- * The offset is the index of the array corresponding to the zero position of the buffer. - *
- * - * @return the offset of the double array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means that this buffer's change of content will be visible to the - * new buffer. The two buffer's position, limit and mark are independent. - *
- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer asReadOnlyBuffer (); - - /** Compacts this double buffer. - *- * The remaining doubles will be moved to the head of the buffer, staring from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *
- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer compact (); - - /** Compare the remaining doubles of this buffer to another double buffer's remaining doubles. - * - * @param otherBuffer another double buffer. - * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is - * greater than {@code other}. - * @exception ClassCastException if {@code other} is not a double buffer. - * @since Android 1.0 */ - public int compareTo (DoubleBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - double thisDouble, otherDouble; - while (compareRemaining > 0) { - thisDouble = get(thisPos); - otherDouble = otherBuffer.get(otherPos); - // checks for double and NaN inequality - if ((thisDouble != otherDouble) && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) { - return thisDouble < otherDouble ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only - * property and byte order are the same as this buffer's, too. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer duplicate (); - - /** Checks whether this double buffer is equal to another object. - *- * If {@code other} is not a double buffer then {@code false} is returned. Two double buffers are equal if and only if their - * remaining doubles are exactly the same. Position, limit, capacity and mark are not considered. - *
- * - * @param other the object to compare with this double buffer. - * @return {@code true} if this double buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof DoubleBuffer)) { - return false; - } - DoubleBuffer otherBuffer = (DoubleBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the double at the current position and increases the position by 1. - * - * @return the double at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract double get (); - - /** Reads doubles from the current position into the specified double array and increases the position by the number of doubles - * read. - *- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *
- * - * @param dest the destination double array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public DoubleBuffer get (double[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads doubles from the current position into the specified double array, starting from the specified offset, and increases - * the position by the number of doubles read. - * - * @param dest the target double array. - * @param off the offset of the double array, must not be negative and not greater than {@code dest.length}. - * @param len the number of doubles to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public DoubleBuffer get (double[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns a double at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a double at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract double get (int index); - - /** Indicates whether this buffer is based on a double array and is read/write. - * - * @return {@code true} if this buffer is based on a double array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - -// /** -// * Calculates this buffer's hash code from the remaining chars. The -// * position, limit, capacity and mark don't affect the hash code. -// * -// * @return the hash code calculated from the remaining chars. -// * @since Android 1.0 -// */ -// public int hashCode() { -// int myPosition = position; -// int hash = 0; -// long l; -// while (myPosition < limit) { -// l = Double.doubleToLongBits(get(myPosition++)); -// hash = hash + ((int) l) ^ ((int) (l >> 32)); -// } -// return hash; -// } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *- * A double buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting doubles from/to bytes. - *- * If this buffer is not based on a byte buffer, then this always returns the platform's native byte order. - *
- * - * @return the byte order used by this buffer when converting doubles from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @see #array() */ - abstract double[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @see #arrayOffset() */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @see #hasArray() */ - abstract boolean protectedHasArray (); - - /** Writes the given double to the current position and increases the position by 1. - * - * @param d the double to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer put (double d); - - /** Writes doubles from the given double array to the current position and increases the position by the number of doubles - * written. - *- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *
- * - * @param src the source double array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final DoubleBuffer put (double[] src) { - return put(src, 0, src.length); - } - - /** Writes doubles from the given double array, starting from the specified offset, to the current position and increases the - * position by the number of doubles written. - * - * @param src the source double array. - * @param off the offset of double array, must not be negative and not greater than {@code src.length}. - * @param len the number of doubles to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public DoubleBuffer put (double[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining doubles of the {@code src} double buffer to this buffer's current position, and increases both - * buffers' position by the number of doubles copied. - * - * @param src the source double buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public DoubleBuffer put (DoubleBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - double[] doubles = new double[src.remaining()]; - src.get(doubles); - put(doubles); - return this; - } - - /** Write a double to the specified index of this buffer and the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param d the double to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer put (int index, double d); - - /** Returns a sliced buffer that shares its content with this buffer. - *- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract DoubleBuffer slice (); - - /** Returns a string representing the state of this double buffer. - * - * @return A string representing the state of this double buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/DoubleToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/DoubleToByteBufferAdapter.java deleted file mode 100644 index 10c9ad9d..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/DoubleToByteBufferAdapter.java +++ /dev/null @@ -1,201 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a double buffer. - *- * Implementation notice: - *
- * FloatArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class FloatArrayBuffer extends FloatBuffer { - - protected final float[] backingArray; - - protected final int offset; - - FloatArrayBuffer (float[] array) { - this(array.length, array, 0); - } - - FloatArrayBuffer (int capacity) { - this(capacity, new float[capacity], 0); - } - - FloatArrayBuffer (int capacity, float[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final float get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final float get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final FloatBuffer get (float[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/FloatBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/FloatBuffer.java deleted file mode 100644 index 9f34720e..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/FloatBuffer.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of floats. - *- * A float buffer can be created in either of the following ways: - *
- *- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *
- * - * @param array the float array which the new buffer will be based on. - * @return the created float buffer. - * @since Android 1.0 */ - public static FloatBuffer wrap (float[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new float buffer by wrapping the given float array. - *- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *
- * - * @param array the float array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created float buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @exception NullPointerException if {@code array} is null. - * @since Android 1.0 */ - public static FloatBuffer wrap (float[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)start + (long)len > array.length) { - throw new IndexOutOfBoundsException(); - } - - FloatBuffer buf = BufferFactory.newFloatBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code FloatBuffer} with given capacity. - * - * @param capacity The capacity of the buffer */ - FloatBuffer (int capacity) { - super(capacity); - } - - /** Returns the float array which this buffer is based on, if there is one. - * - * @return the float array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final float[] array () { - return protectedArray(); - } - - /** Returns the offset of the float array which this buffer is based on, if there is one. - *- * The offset is the index of the array and corresponds to the zero position of the buffer. - *
- * - * @return the offset of the float array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer. - *
- *- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *
- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer asReadOnlyBuffer (); - - /** Compacts this float buffer. - *- * The remaining floats will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *
- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer compact (); - - /** Compare the remaining floats of this buffer to another float buffer's remaining floats. - * - * @param otherBuffer another float buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer}. - * @exception ClassCastException if {@code otherBuffer} is not a float buffer. - * @since Android 1.0 */ - public int compareTo (FloatBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - float thisFloat, otherFloat; - while (compareRemaining > 0) { - thisFloat = get(thisPos); - otherFloat = otherBuffer.get(otherPos); - // checks for float and NaN inequality - if ((thisFloat != otherFloat) && ((thisFloat == thisFloat) || (otherFloat == otherFloat))) { - return thisFloat < otherFloat ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are same as this buffer too. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer duplicate (); - - /** Checks whether this float buffer is equal to another object. - *- * If {@code other} is not a float buffer then {@code false} is returned. Two float buffers are equal if and only if their - * remaining floats are exactly the same. Position, limit, capacity and mark are not considered. - *
- * - * @param other the object to compare with this float buffer. - * @return {@code true} if this float buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof FloatBuffer)) { - return false; - } - FloatBuffer otherBuffer = (FloatBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the float at the current position and increases the position by 1. - * - * @return the float at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract float get (); - - /** Reads floats from the current position into the specified float array and increases the position by the number of floats - * read. - *- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *
- * - * @param dest the destination float array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public FloatBuffer get (float[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads floats from the current position into the specified float array, starting from the specified offset, and increases the - * position by the number of floats read. - * - * @param dest the target float array. - * @param off the offset of the float array, must not be negative and no greater than {@code dest.length}. - * @param len the number of floats to read, must be no less than zero and no greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public FloatBuffer get (float[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns a float at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a float at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract float get (int index); - - /** Indicates whether this buffer is based on a float array and is read/write. - * - * @return {@code true} if this buffer is based on a float array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - -// /** -// * Calculates this buffer's hash code from the remaining chars. The -// * position, limit, capacity and mark don't affect the hash code. -// * -// * @return the hash code calculated from the remaining floats. -// * @since Android 1.0 -// */ -// public int hashCode() { -// int myPosition = position; -// int hash = 0; -// while (myPosition < limit) { -// hash = hash + Float.floatToIntBits(get(myPosition++)); -// } -// return hash; -// } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *- * A float buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting floats from/to bytes. - *- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *
- * - * @return the byte order used by this buffer when converting floats from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - abstract float[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - abstract boolean protectedHasArray (); - - /** Writes the given float to the current position and increases the position by 1. - * - * @param f the float to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer put (float f); - - /** Writes floats from the given float array to the current position and increases the position by the number of floats written. - *- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *
- * - * @param src the source float array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final FloatBuffer put (float[] src) { - return put(src, 0, src.length); - } - - /** Writes floats from the given float array, starting from the specified offset, to the current position and increases the - * position by the number of floats written. - * - * @param src the source float array. - * @param off the offset of float array, must not be negative and not greater than {@code src.length}. - * @param len the number of floats to write, must be no less than zero and no greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public FloatBuffer put (float[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining floats of the {@code src} float buffer to this buffer's current position, and increases both - * buffers' position by the number of floats copied. - * - * @param src the source float buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public FloatBuffer put (FloatBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - float[] contents = new float[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a float to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param f the float to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer put (int index, float f); - - /** Returns a sliced buffer that shares its content with this buffer. - *- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract FloatBuffer slice (); - - /** Returns a string representing the state of this float buffer. - * - * @return a string representing the state of this float buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/FloatToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/FloatToByteBufferAdapter.java deleted file mode 100644 index c0722b7a..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/FloatToByteBufferAdapter.java +++ /dev/null @@ -1,201 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a float buffer. - *- * Implementation notice: - *
- * HeapByteBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class HeapByteBuffer extends BaseByteBuffer { - - protected final byte[] backingArray; - - protected final int offset; - - HeapByteBuffer (byte[] backingArray) { - this(backingArray, backingArray.length, 0); - } - - HeapByteBuffer (int capacity) { - this(new byte[capacity], capacity, 0); - } - - HeapByteBuffer (byte[] backingArray, int capacity, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - - if (offset + capacity > backingArray.length) { - throw new IndexOutOfBoundsException(); - } - } - - /* - * Override ByteBuffer.get(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#get(byte[], int, int) - */ - public final ByteBuffer get (byte[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final byte get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final byte get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final double getDouble () { - return Numbers.longBitsToDouble(getLong()); - } - - public final double getDouble (int index) { - return Numbers.longBitsToDouble(getLong(index)); - } - - public final float getFloat () { - return Numbers.intBitsToFloat(getInt()); - } - - public final float getFloat (int index) { - return Numbers.intBitsToFloat(getInt(index)); - } - - public final int getInt () { - int newPosition = position + 4; - if (newPosition > limit) { - throw new BufferUnderflowException(); - } - int result = loadInt(position); - position = newPosition; - return result; - } - - public final int getInt (int index) { - if (index < 0 || index + 4 > limit) { - throw new IndexOutOfBoundsException(); - } - return loadInt(index); - } - - public final long getLong () { - int newPosition = position + 8; - if (newPosition > limit) { - throw new BufferUnderflowException(); - } - long result = loadLong(position); - position = newPosition; - return result; - } - - public final long getLong (int index) { - if (index < 0 || index + 8 > limit) { - throw new IndexOutOfBoundsException(); - } - return loadLong(index); - } - - public final short getShort () { - int newPosition = position + 2; - if (newPosition > limit) { - throw new BufferUnderflowException(); - } - short result = loadShort(position); - position = newPosition; - return result; - } - - public final short getShort (int index) { - if (index < 0 || index + 2 > limit) { - throw new IndexOutOfBoundsException(); - } - return loadShort(index); - } - - public final boolean isDirect () { - return false; - } - - protected final int loadInt (int index) { - int baseOffset = offset + index; - int bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 4; i++) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } else { - for (int i = 3; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } - return bytes; - } - - protected final long loadLong (int index) { - int baseOffset = offset + index; - long bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 0; i < 8; i++) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } else { - for (int i = 7; i >= 0; i--) { - bytes = bytes << 8; - bytes = bytes | (backingArray[baseOffset + i] & 0xFF); - } - } - return bytes; - } - - protected final short loadShort (int index) { - int baseOffset = offset + index; - short bytes = 0; - if (order == Endianness.BIG_ENDIAN) { - bytes = (short)(backingArray[baseOffset] << 8); - bytes |= (backingArray[baseOffset + 1] & 0xFF); - } else { - bytes = (short)(backingArray[baseOffset + 1] << 8); - bytes |= (backingArray[baseOffset] & 0xFF); - } - return bytes; - } - - protected final void store (int index, int value) { - int baseOffset = offset + index; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 3; i >= 0; i--) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } else { - for (int i = 0; i <= 3; i++) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } - } - - protected final void store (int index, long value) { - int baseOffset = offset + index; - if (order == Endianness.BIG_ENDIAN) { - for (int i = 7; i >= 0; i--) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } else { - for (int i = 0; i <= 7; i++) { - backingArray[baseOffset + i] = (byte)(value & 0xFF); - value = value >> 8; - } - } - } - - protected final void store (int index, short value) { - int baseOffset = offset + index; - if (order == Endianness.BIG_ENDIAN) { - backingArray[baseOffset] = (byte)((value >> 8) & 0xFF); - backingArray[baseOffset + 1] = (byte)(value & 0xFF); - } else { - backingArray[baseOffset + 1] = (byte)((value >> 8) & 0xFF); - backingArray[baseOffset] = (byte)(value & 0xFF); - } - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/IntArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/IntArrayBuffer.java deleted file mode 100644 index 10a62ad4..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/IntArrayBuffer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose the implementation of array based int buffers. - *- * IntArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class IntArrayBuffer extends IntBuffer { - - protected final int[] backingArray; - - protected final int offset; - - IntArrayBuffer (int[] array) { - this(array.length, array, 0); - } - - IntArrayBuffer (int capacity) { - this(capacity, new int[capacity], 0); - } - - IntArrayBuffer (int capacity, int[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final int get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final int get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final IntBuffer get (int[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/IntBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/IntBuffer.java deleted file mode 100644 index dab83306..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/IntBuffer.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of ints. - *- * A int buffer can be created in either of the following ways: - *
- *- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *
- * - * @param array the int array which the new buffer will be based on. - * @return the created int buffer. - * @since Android 1.0 */ - public static IntBuffer wrap (int[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new int buffer by wrapping the given int array. - *- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *
- * - * @param array the int array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length} - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created int buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static IntBuffer wrap (int[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)len + (long)start > array.length) { - throw new IndexOutOfBoundsException(); - } - IntBuffer buf = BufferFactory.newIntBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code IntBuffer} with given capacity. - * - * @param capacity the capacity of the buffer. */ - IntBuffer (int capacity) { - super(capacity); - } - - /** Returns the int array which this buffer is based on, if there is one. - * - * @return the int array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int[] array () { - return protectedArray(); - } - - /** Returns the offset of the int array which this buffer is based on, if there is one. - *- * The offset is the index of the array corresponds to the zero position of the buffer. - *
- * - * @return the offset of the int array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *- * The returned buffer is guaranteed to be a new instance, even this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *
- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer asReadOnlyBuffer (); - - /** Compacts this int buffer. - *- * The remaining ints will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *
- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer compact (); - - /** Compares the remaining ints of this buffer to another int buffer's remaining ints. - * - * @param otherBuffer another int buffer. - * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is - * greater than {@code other}. - * @exception ClassCastException if {@code other} is not an int buffer. - * @since Android 1.0 */ - public int compareTo (IntBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - int thisInt, otherInt; - while (compareRemaining > 0) { - thisInt = get(thisPos); - otherInt = otherBuffer.get(otherPos); - if (thisInt != otherInt) { - return thisInt < otherInt ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract IntBuffer duplicate (); - - /** Checks whether this int buffer is equal to another object. - *- * If {@code other} is not a int buffer then {@code false} is returned. Two int buffers are equal if and only if their remaining - * ints are exactly the same. Position, limit, capacity and mark are not considered. - *
- * - * @param other the object to compare with this int buffer. - * @return {@code true} if this int buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof IntBuffer)) { - return false; - } - IntBuffer otherBuffer = (IntBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the int at the current position and increases the position by 1. - * - * @return the int at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract int get (); - - /** Reads ints from the current position into the specified int array and increases the position by the number of ints read. - *- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *
- * - * @param dest the destination int array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public IntBuffer get (int[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads ints from the current position into the specified int array, starting from the specified offset, and increases the - * position by the number of ints read. - * - * @param dest the target int array. - * @param off the offset of the int array, must not be negative and not greater than {@code dest.length}. - * @param len the number of ints to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public IntBuffer get (int[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns an int at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return an int at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract int get (int index); - - /** Indicates whether this buffer is based on a int array and is read/write. - * - * @return {@code true} if this buffer is based on a int array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining ints. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *- * An int buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting ints from/to bytes. - *- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *
- * - * @return the byte order used by this buffer when converting ints from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - protected abstract int[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - protected abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - protected abstract boolean protectedHasArray (); - - /** Writes the given int to the current position and increases the position by 1. - * - * @param i the int to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer put (int i); - - /** Writes ints from the given int array to the current position and increases the position by the number of ints written. - *- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *
- * - * @param src the source int array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final IntBuffer put (int[] src) { - return put(src, 0, src.length); - } - - /** Writes ints from the given int array, starting from the specified offset, to the current position and increases the position - * by the number of ints written. - * - * @param src the source int array. - * @param off the offset of int array, must not be negative and not greater than {@code src.length}. - * @param len the number of ints to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public IntBuffer put (int[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining ints of the {@code src} int buffer to this buffer's current position, and increases both buffers' - * position by the number of ints copied. - * - * @param src the source int buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public IntBuffer put (IntBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - int[] contents = new int[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Write a int to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param i the int to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract IntBuffer put (int index, int i); - - /** Returns a sliced buffer that shares its content with this buffer. - *- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract IntBuffer slice (); - - /** Returns a string represents of the state of this int buffer. - * - * @return a string represents of the state of this int buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/IntToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/IntToByteBufferAdapter.java deleted file mode 100644 index f2151ff5..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/IntToByteBufferAdapter.java +++ /dev/null @@ -1,205 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a int buffer. - *- * Implementation notice: - *
- * LongArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class LongArrayBuffer extends LongBuffer { - - protected final long[] backingArray; - - protected final int offset; - - LongArrayBuffer (long[] array) { - this(array.length, array, 0); - } - - LongArrayBuffer (int capacity) { - this(capacity, new long[capacity], 0); - } - - LongArrayBuffer (int capacity, long[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final long get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final long get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final LongBuffer get (long[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/LongBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/LongBuffer.java deleted file mode 100644 index 53a226fb..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/LongBuffer.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of longs. - *- * A long buffer can be created in either of the following ways: - *
- *- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *
- * - * @param array the long array which the new buffer will be based on. - * @return the created long buffer. - * @since Android 1.0 */ - public static LongBuffer wrap (long[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new long buffer by wrapping the given long array. - *- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *
- * - * @param array the long array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created long buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static LongBuffer wrap (long[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)len + (long)start > array.length) { - throw new IndexOutOfBoundsException(); - } - - LongBuffer buf = BufferFactory.newLongBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code LongBuffer} with given capacity. - * - * @param capacity The capacity of the buffer */ - LongBuffer (int capacity) { - super(capacity); - } - - /** Returns the long array which this buffer is based on, if there is one. - * - * @return the long array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final long[] array () { - return protectedArray(); - } - - /** Returns the offset of the long array which this buffer is based on, if there is one. - *- * The offset is the index of the array and corresponds to the zero position of the buffer. - *
- * - * @return the offset of the long array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *
- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer asReadOnlyBuffer (); - - /** Compacts this long buffer. - *- * The remaining longs will be moved to the head of the buffer, staring from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *
- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer compact (); - - /** Compare the remaining longs of this buffer to another long buffer's remaining longs. - * - * @param otherBuffer another long buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer} - * @exception ClassCastException if {@code otherBuffer} is not a long buffer. - * @since Android 1.0 */ - public int compareTo (LongBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - // BEGIN android-changed - long thisLong, otherLong; - while (compareRemaining > 0) { - thisLong = get(thisPos); - otherLong = otherBuffer.get(otherPos); - if (thisLong != otherLong) { - return thisLong < otherLong ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - // END android-changed - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are same as this buffer's, too. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract LongBuffer duplicate (); - - /** Checks whether this long buffer is equal to another object. - *- * If {@code other} is not a long buffer then {@code false} is returned. Two long buffers are equal if and only if their - * remaining longs are exactly the same. Position, limit, capacity and mark are not considered. - *
- * - * @param other the object to compare with this long buffer. - * @return {@code true} if this long buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof LongBuffer)) { - return false; - } - LongBuffer otherBuffer = (LongBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the long at the current position and increase the position by 1. - * - * @return the long at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract long get (); - - /** Reads longs from the current position into the specified long array and increases the position by the number of longs read. - *- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *
- * - * @param dest the destination long array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public LongBuffer get (long[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads longs from the current position into the specified long array, starting from the specified offset, and increase the - * position by the number of longs read. - * - * @param dest the target long array. - * @param off the offset of the long array, must not be negative and not greater than {@code dest.length}. - * @param len the number of longs to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public LongBuffer get (long[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns the long at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return the long at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract long get (int index); - - /** Indicates whether this buffer is based on a long array and is read/write. - * - * @return {@code true} if this buffer is based on a long array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining longs. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - long l; - while (myPosition < limit) { - l = get(myPosition++); - hash = hash + ((int)l) ^ ((int)(l >> 32)); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *- * A long buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting longs from/to bytes. - *- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *
- * - * @return the byte order used by this buffer when converting longs from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - abstract long[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - abstract boolean protectedHasArray (); - - /** Writes the given long to the current position and increases the position by 1. - * - * @param l the long to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer put (long l); - - /** Writes longs from the given long array to the current position and increases the position by the number of longs written. - *- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *
- * - * @param src the source long array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final LongBuffer put (long[] src) { - return put(src, 0, src.length); - } - - /** Writes longs from the given long array, starting from the specified offset, to the current position and increases the - * position by the number of longs written. - * - * @param src the source long array. - * @param off the offset of long array, must not be negative and not greater than {@code src.length}. - * @param len the number of longs to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public LongBuffer put (long[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining longs of the {@code src} long buffer to this buffer's current position, and increases both buffers' - * position by the number of longs copied. - * - * @param src the source long buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public LongBuffer put (LongBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - long[] contents = new long[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a long to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param l the long to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract LongBuffer put (int index, long l); - - /** Returns a sliced buffer that shares its content with this buffer. - *- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract LongBuffer slice (); - - /** Returns a string representing the state of this long buffer. - * - * @return a string representing the state of this long buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/LongToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/LongToByteBufferAdapter.java deleted file mode 100644 index 410b3b30..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/LongToByteBufferAdapter.java +++ /dev/null @@ -1,200 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a long buffer. - *- * Implementation notice: - *
- * ReadOnlyCharArrayBuffer extends CharArrayBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadOnlyCharArrayBuffer extends CharArrayBuffer { - - static ReadOnlyCharArrayBuffer copy (CharArrayBuffer other, int markOfOther) { - ReadOnlyCharArrayBuffer buf = new ReadOnlyCharArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyCharArrayBuffer (int capacity, char[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public CharBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public CharBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public CharBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected char[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public CharBuffer put (char c) { - throw new ReadOnlyBufferException(); - } - - public CharBuffer put (int index, char c) { - throw new ReadOnlyBufferException(); - } - - public final CharBuffer put (char[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public final CharBuffer put (CharBuffer src) { - throw new ReadOnlyBufferException(); - } - - public CharBuffer put (String src, int start, int end) { - if ((start < 0) || (end < 0) || (long)start + (long)end > src.length()) { - throw new IndexOutOfBoundsException(); - } - throw new ReadOnlyBufferException(); - } - - public CharBuffer slice () { - return new ReadOnlyCharArrayBuffer(remaining(), backingArray, offset + position); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyDoubleArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyDoubleArrayBuffer.java deleted file mode 100644 index 372ac4e3..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyDoubleArrayBuffer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** DoubleArrayBuffer, ReadWriteDoubleArrayBuffer and ReadOnlyDoubleArrayBuffer compose the implementation of array based double - * buffers. - *- * ReadOnlyDoubleArrayBuffer extends DoubleArrayBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadOnlyDoubleArrayBuffer extends DoubleArrayBuffer { - - static ReadOnlyDoubleArrayBuffer copy (DoubleArrayBuffer other, int markOfOther) { - ReadOnlyDoubleArrayBuffer buf = new ReadOnlyDoubleArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyDoubleArrayBuffer (int capacity, double[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public DoubleBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public DoubleBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected double[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public DoubleBuffer put (double c) { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer put (int index, double c) { - throw new ReadOnlyBufferException(); - } - - public final DoubleBuffer put (double[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public final DoubleBuffer put (DoubleBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public DoubleBuffer slice () { - return new ReadOnlyDoubleArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyFloatArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyFloatArrayBuffer.java deleted file mode 100644 index 9bb46e2c..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyFloatArrayBuffer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** FloatArrayBuffer, ReadWriteFloatArrayBuffer and ReadOnlyFloatArrayBuffer compose the implementation of array based float - * buffers. - *- * ReadOnlyFloatArrayBuffer extends FloatArrayBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadOnlyFloatArrayBuffer extends FloatArrayBuffer { - - static ReadOnlyFloatArrayBuffer copy (FloatArrayBuffer other, int markOfOther) { - ReadOnlyFloatArrayBuffer buf = new ReadOnlyFloatArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyFloatArrayBuffer (int capacity, float[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public FloatBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public FloatBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected float[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public FloatBuffer put (float c) { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer put (int index, float c) { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer put (FloatBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public final FloatBuffer put (float[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public FloatBuffer slice () { - return new ReadOnlyFloatArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyHeapByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyHeapByteBuffer.java deleted file mode 100644 index 5e6a4671..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyHeapByteBuffer.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers. - *- * ReadOnlyHeapByteBuffer extends HeapByteBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadOnlyHeapByteBuffer extends HeapByteBuffer { - - static ReadOnlyHeapByteBuffer copy (HeapByteBuffer other, int markOfOther) { - ReadOnlyHeapByteBuffer buf = new ReadOnlyHeapByteBuffer(other.backingArray, other.capacity(), other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - ReadOnlyHeapByteBuffer (byte[] backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public ByteBuffer asReadOnlyBuffer () { - return copy(this, mark); - } - - public ByteBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected byte[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public ByteBuffer put (byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (int index, byte b) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (byte[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putDouble (int index, double value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putFloat (int index, float value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putInt (int index, int value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (int index, long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putLong (long value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (int index, short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer putShort (short value) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer put (ByteBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public ByteBuffer slice () { - ReadOnlyHeapByteBuffer slice = new ReadOnlyHeapByteBuffer(backingArray, remaining(), offset + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyIntArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyIntArrayBuffer.java deleted file mode 100644 index 228db222..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyIntArrayBuffer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose the implementation of array based int buffers. - *- * ReadOnlyIntArrayBuffer extends IntArrayBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadOnlyIntArrayBuffer extends IntArrayBuffer { - - static ReadOnlyIntArrayBuffer copy (IntArrayBuffer other, int markOfOther) { - ReadOnlyIntArrayBuffer buf = new ReadOnlyIntArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyIntArrayBuffer (int capacity, int[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public IntBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public IntBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public IntBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected int[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public IntBuffer put (int c) { - throw new ReadOnlyBufferException(); - } - - public IntBuffer put (int index, int c) { - throw new ReadOnlyBufferException(); - } - - public IntBuffer put (IntBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public final IntBuffer put (int[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public IntBuffer slice () { - return new ReadOnlyIntArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyLongArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyLongArrayBuffer.java deleted file mode 100644 index bca9209b..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyLongArrayBuffer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** LongArrayBuffer, ReadWriteLongArrayBuffer and ReadOnlyLongArrayBuffer compose the implementation of array based long buffers. - *- * ReadOnlyLongArrayBuffer extends LongArrayBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadOnlyLongArrayBuffer extends LongArrayBuffer { - - static ReadOnlyLongArrayBuffer copy (LongArrayBuffer other, int markOfOther) { - ReadOnlyLongArrayBuffer buf = new ReadOnlyLongArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyLongArrayBuffer (int capacity, long[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public LongBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public LongBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public LongBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected long[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public LongBuffer put (long c) { - throw new ReadOnlyBufferException(); - } - - public LongBuffer put (int index, long c) { - throw new ReadOnlyBufferException(); - } - - public LongBuffer put (LongBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public final LongBuffer put (long[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public LongBuffer slice () { - return new ReadOnlyLongArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyShortArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyShortArrayBuffer.java deleted file mode 100644 index 7d9dbda5..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadOnlyShortArrayBuffer.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer compose the implementation of array based short - * buffers. - *- * ReadOnlyShortArrayBuffer extends ShortArrayBuffer with all the write methods throwing read only exception. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadOnlyShortArrayBuffer extends ShortArrayBuffer { - - static ReadOnlyShortArrayBuffer copy (ShortArrayBuffer other, int markOfOther) { - ReadOnlyShortArrayBuffer buf = new ReadOnlyShortArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadOnlyShortArrayBuffer (int capacity, short[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public ShortBuffer asReadOnlyBuffer () { - return duplicate(); - } - - public ShortBuffer compact () { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return true; - } - - protected short[] protectedArray () { - throw new ReadOnlyBufferException(); - } - - protected int protectedArrayOffset () { - throw new ReadOnlyBufferException(); - } - - protected boolean protectedHasArray () { - return false; - } - - public ShortBuffer put (ShortBuffer buf) { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer put (short c) { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer put (int index, short c) { - throw new ReadOnlyBufferException(); - } - - public final ShortBuffer put (short[] src, int off, int len) { - throw new ReadOnlyBufferException(); - } - - public ShortBuffer slice () { - return new ReadOnlyShortArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteCharArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteCharArrayBuffer.java deleted file mode 100644 index 3c1b55e4..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteCharArrayBuffer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** CharArrayBuffer, ReadWriteCharArrayBuffer and ReadOnlyCharArrayBuffer compose the implementation of array based char buffers. - *- * ReadWriteCharArrayBuffer extends CharArrayBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadWriteCharArrayBuffer extends CharArrayBuffer { - - static ReadWriteCharArrayBuffer copy (CharArrayBuffer other, int markOfOther) { - ReadWriteCharArrayBuffer buf = new ReadWriteCharArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteCharArrayBuffer (char[] array) { - super(array); - } - - ReadWriteCharArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteCharArrayBuffer (int capacity, char[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public CharBuffer asReadOnlyBuffer () { - return ReadOnlyCharArrayBuffer.copy(this, mark); - } - - public CharBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public CharBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected char[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public CharBuffer put (char c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public CharBuffer put (int index, char c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public CharBuffer put (char[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)len + (long)off > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public CharBuffer slice () { - return new ReadWriteCharArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteDoubleArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteDoubleArrayBuffer.java deleted file mode 100644 index 336a0010..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteDoubleArrayBuffer.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** DoubleArrayBuffer, ReadWriteDoubleArrayBuffer and ReadOnlyDoubleArrayBuffer compose the implementation of array based double - * buffers. - *- * ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadWriteDoubleArrayBuffer extends DoubleArrayBuffer { - - static ReadWriteDoubleArrayBuffer copy (DoubleArrayBuffer other, int markOfOther) { - ReadWriteDoubleArrayBuffer buf = new ReadWriteDoubleArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteDoubleArrayBuffer (double[] array) { - super(array); - } - - ReadWriteDoubleArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteDoubleArrayBuffer (int capacity, double[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public DoubleBuffer asReadOnlyBuffer () { - return ReadOnlyDoubleArrayBuffer.copy(this, mark); - } - - public DoubleBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public DoubleBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected double[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public DoubleBuffer put (double c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public DoubleBuffer put (int index, double c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public DoubleBuffer put (double[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public DoubleBuffer slice () { - return new ReadWriteDoubleArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteFloatArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteFloatArrayBuffer.java deleted file mode 100644 index 87935220..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteFloatArrayBuffer.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** FloatArrayBuffer, ReadWriteFloatArrayBuffer and ReadOnlyFloatArrayBuffer compose the implementation of array based float - * buffers. - *- * ReadWriteFloatArrayBuffer extends FloatArrayBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadWriteFloatArrayBuffer extends FloatArrayBuffer { - - static ReadWriteFloatArrayBuffer copy (FloatArrayBuffer other, int markOfOther) { - ReadWriteFloatArrayBuffer buf = new ReadWriteFloatArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteFloatArrayBuffer (float[] array) { - super(array); - } - - ReadWriteFloatArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteFloatArrayBuffer (int capacity, float[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public FloatBuffer asReadOnlyBuffer () { - return ReadOnlyFloatArrayBuffer.copy(this, mark); - } - - public FloatBuffer compact () { -// System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - for (int i = position + offset, j = offset, k = 0; k < remaining(); i++, j++, k++) { - backingArray[j] = backingArray[i]; - } - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public FloatBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected float[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public FloatBuffer put (float c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public FloatBuffer put (int index, float c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public FloatBuffer put (float[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public FloatBuffer slice () { - return new ReadWriteFloatArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteHeapByteBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteHeapByteBuffer.java deleted file mode 100644 index 72becafd..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteHeapByteBuffer.java +++ /dev/null @@ -1,196 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -import java.io.Numbers; - -/** HeapByteBuffer, ReadWriteHeapByteBuffer and ReadOnlyHeapByteBuffer compose the implementation of array based byte buffers. - *- * ReadWriteHeapByteBuffer extends HeapByteBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadWriteHeapByteBuffer extends HeapByteBuffer { - - static ReadWriteHeapByteBuffer copy (HeapByteBuffer other, int markOfOther) { - ReadWriteHeapByteBuffer buf = new ReadWriteHeapByteBuffer(other.backingArray, other.capacity(), other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - buf.order(other.order()); - return buf; - } - - ReadWriteHeapByteBuffer (byte[] backingArray) { - super(backingArray); - } - - ReadWriteHeapByteBuffer (int capacity) { - super(capacity); - } - - ReadWriteHeapByteBuffer (byte[] backingArray, int capacity, int arrayOffset) { - super(backingArray, capacity, arrayOffset); - } - - public ByteBuffer asReadOnlyBuffer () { - return ReadOnlyHeapByteBuffer.copy(this, mark); - } - - public ByteBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public ByteBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected byte[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public ByteBuffer put (byte b) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = b; - return this; - } - - public ByteBuffer put (int index, byte b) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = b; - return this; - } - - /* - * Override ByteBuffer.put(byte[], int, int) to improve performance. - * - * (non-Javadoc) - * - * @see java.nio.ByteBuffer#put(byte[], int, int) - */ - public ByteBuffer put (byte[] src, int off, int len) { - if (off < 0 || len < 0 || (long)off + (long)len > src.length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - if (isReadOnly()) { - throw new ReadOnlyBufferException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public ByteBuffer putDouble (double value) { - return putLong(Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putDouble (int index, double value) { - return putLong(index, Numbers.doubleToRawLongBits(value)); - } - - public ByteBuffer putFloat (float value) { - return putInt(Numbers.floatToIntBits(value)); - } - - public ByteBuffer putFloat (int index, float value) { - return putInt(index, Numbers.floatToIntBits(value)); - } - - public ByteBuffer putInt (int value) { - int newPosition = position + 4; - if (newPosition > limit) { - throw new BufferOverflowException(); - } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putInt (int index, int value) { - if (index < 0 || (long)index + 4 > limit) { - throw new IndexOutOfBoundsException(); - } - store(index, value); - return this; - } - - public ByteBuffer putLong (int index, long value) { - if (index < 0 || (long)index + 8 > limit) { - throw new IndexOutOfBoundsException(); - } - store(index, value); - return this; - } - - public ByteBuffer putLong (long value) { - int newPosition = position + 8; - if (newPosition > limit) { - throw new BufferOverflowException(); - } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer putShort (int index, short value) { - if (index < 0 || (long)index + 2 > limit) { - throw new IndexOutOfBoundsException(); - } - store(index, value); - return this; - } - - public ByteBuffer putShort (short value) { - int newPosition = position + 2; - if (newPosition > limit) { - throw new BufferOverflowException(); - } - store(position, value); - position = newPosition; - return this; - } - - public ByteBuffer slice () { - ReadWriteHeapByteBuffer slice = new ReadWriteHeapByteBuffer(backingArray, remaining(), offset + position); - slice.order = order; - return slice; - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteIntArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteIntArrayBuffer.java deleted file mode 100644 index 34592717..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteIntArrayBuffer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose the implementation of array based int buffers. - *- * ReadWriteIntArrayBuffer extends IntArrayBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadWriteIntArrayBuffer extends IntArrayBuffer { - - static ReadWriteIntArrayBuffer copy (IntArrayBuffer other, int markOfOther) { - ReadWriteIntArrayBuffer buf = new ReadWriteIntArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteIntArrayBuffer (int[] array) { - super(array); - } - - ReadWriteIntArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteIntArrayBuffer (int capacity, int[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public IntBuffer asReadOnlyBuffer () { - return ReadOnlyIntArrayBuffer.copy(this, mark); - } - - public IntBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public IntBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected int[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public IntBuffer put (int c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public IntBuffer put (int index, int c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public IntBuffer put (int[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public IntBuffer slice () { - return new ReadWriteIntArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteLongArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteLongArrayBuffer.java deleted file mode 100644 index bff78528..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteLongArrayBuffer.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** LongArrayBuffer, ReadWriteLongArrayBuffer and ReadOnlyLongArrayBuffer compose the implementation of array based long buffers. - *- * ReadWriteLongArrayBuffer extends LongArrayBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadWriteLongArrayBuffer extends LongArrayBuffer { - - static ReadWriteLongArrayBuffer copy (LongArrayBuffer other, int markOfOther) { - ReadWriteLongArrayBuffer buf = new ReadWriteLongArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteLongArrayBuffer (long[] array) { - super(array); - } - - ReadWriteLongArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteLongArrayBuffer (int capacity, long[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public LongBuffer asReadOnlyBuffer () { - return ReadOnlyLongArrayBuffer.copy(this, mark); - } - - public LongBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public LongBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected long[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public LongBuffer put (long c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public LongBuffer put (int index, long c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public LongBuffer put (long[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public LongBuffer slice () { - return new ReadWriteLongArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteShortArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ReadWriteShortArrayBuffer.java deleted file mode 100644 index 7c32bcce..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ReadWriteShortArrayBuffer.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer compose the implementation of array based short - * buffers. - *- * ReadWriteShortArrayBuffer extends ShortArrayBuffer with all the write methods. - *
- *- * This class is marked final for runtime performance. - *
*/ -final class ReadWriteShortArrayBuffer extends ShortArrayBuffer { - - static ReadWriteShortArrayBuffer copy (ShortArrayBuffer other, int markOfOther) { - ReadWriteShortArrayBuffer buf = new ReadWriteShortArrayBuffer(other.capacity(), other.backingArray, other.offset); - buf.limit = other.limit(); - buf.position = other.position(); - buf.mark = markOfOther; - return buf; - } - - ReadWriteShortArrayBuffer (short[] array) { - super(array); - } - - ReadWriteShortArrayBuffer (int capacity) { - super(capacity); - } - - ReadWriteShortArrayBuffer (int capacity, short[] backingArray, int arrayOffset) { - super(capacity, backingArray, arrayOffset); - } - - public ShortBuffer asReadOnlyBuffer () { - return ReadOnlyShortArrayBuffer.copy(this, mark); - } - - public ShortBuffer compact () { - System.arraycopy(backingArray, position + offset, backingArray, offset, remaining()); - position = limit - position; - limit = capacity; - mark = UNSET_MARK; - return this; - } - - public ShortBuffer duplicate () { - return copy(this, mark); - } - - public boolean isReadOnly () { - return false; - } - - protected short[] protectedArray () { - return backingArray; - } - - protected int protectedArrayOffset () { - return offset; - } - - protected boolean protectedHasArray () { - return true; - } - - public ShortBuffer put (short c) { - if (position == limit) { - throw new BufferOverflowException(); - } - backingArray[offset + position++] = c; - return this; - } - - public ShortBuffer put (int index, short c) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - backingArray[offset + index] = c; - return this; - } - - public ShortBuffer put (short[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferOverflowException(); - } - System.arraycopy(src, off, backingArray, offset + position, len); - position += len; - return this; - } - - public ShortBuffer slice () { - return new ReadWriteShortArrayBuffer(remaining(), backingArray, offset + position); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ShortArrayBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ShortArrayBuffer.java deleted file mode 100644 index fce335df..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ShortArrayBuffer.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** ShortArrayBuffer, ReadWriteShortArrayBuffer and ReadOnlyShortArrayBuffer compose the implementation of array based short - * buffers. - *- * ShortArrayBuffer implements all the shared readonly methods and is extended by the other two classes. - *
- *- * All methods are marked final for runtime performance. - *
*/ -abstract class ShortArrayBuffer extends ShortBuffer { - - protected final short[] backingArray; - - protected final int offset; - - ShortArrayBuffer (short[] array) { - this(array.length, array, 0); - } - - ShortArrayBuffer (int capacity) { - this(capacity, new short[capacity], 0); - } - - ShortArrayBuffer (int capacity, short[] backingArray, int offset) { - super(capacity); - this.backingArray = backingArray; - this.offset = offset; - } - - public final short get () { - if (position == limit) { - throw new BufferUnderflowException(); - } - return backingArray[offset + position++]; - } - - public final short get (int index) { - if (index < 0 || index >= limit) { - throw new IndexOutOfBoundsException(); - } - return backingArray[offset + index]; - } - - public final ShortBuffer get (short[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - System.arraycopy(backingArray, offset + position, dest, off, len); - position += len; - return this; - } - - public final boolean isDirect () { - return false; - } - - public final ByteOrder order () { - return ByteOrder.nativeOrder(); - } - -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ShortBuffer.java b/backends/gdx-backend-dragome/emu/java/nio/ShortBuffer.java deleted file mode 100644 index 817cc48e..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ShortBuffer.java +++ /dev/null @@ -1,427 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -/** A buffer of shorts. - *- * A short buffer can be created in either of the following ways: - *
- *- * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. - *
- * - * @param array the short array which the new buffer will be based on. - * @return the created short buffer. - * @since Android 1.0 */ - public static ShortBuffer wrap (short[] array) { - return wrap(array, 0, array.length); - } - - /** Creates a new short buffer by wrapping the given short array. - *- * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the array. - *
- * - * @param array the short array which the new buffer will be based on. - * @param start the start index, must not be negative and not greater than {@code array.length}. - * @param len the length, must not be negative and not greater than {@code array.length - start}. - * @return the created short buffer. - * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. - * @since Android 1.0 */ - public static ShortBuffer wrap (short[] array, int start, int len) { - if (array == null) { - throw new NullPointerException(); - } - if (start < 0 || len < 0 || (long)start + (long)len > array.length) { - throw new IndexOutOfBoundsException(); - } - - ShortBuffer buf = BufferFactory.newShortBuffer(array); - buf.position = start; - buf.limit = start + len; - - return buf; - } - - /** Constructs a {@code ShortBuffer} with given capacity. - * - * @param capacity The capacity of the buffer */ - ShortBuffer (int capacity) { - super(capacity); - } - - /** Returns the short array which this buffer is based on, if there is one. - * - * @return the short array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final short[] array () { - return protectedArray(); - } - - /** Returns the offset of the short array which this buffer is based on, if there is one. - *- * The offset is the index of the array corresponding to the zero position of the buffer. - *
- * - * @return the offset of the short array which this buffer is based on. - * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. - * @exception UnsupportedOperationException if this buffer is not based on an array. - * @since Android 1.0 */ - public final int arrayOffset () { - return protectedArrayOffset(); - } - - /** Returns a read-only buffer that shares its content with this buffer. - *- * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, - * limit, capacity and mark are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new - * buffer. The two buffer's position, limit and mark are independent. - *
- * - * @return a read-only version of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer asReadOnlyBuffer (); - - /** Compacts this short buffer. - *- * The remaining shorts will be moved to the head of the buffer, starting from position zero. Then the position is set to - * {@code remaining()}; the limit is set to capacity; the mark is cleared. - *
- * - * @return this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer compact (); - - /** Compare the remaining shorts of this buffer to another short buffer's remaining shorts. - * - * @param otherBuffer another short buffer. - * @return a negative value if this is less than {@code otherBuffer}; 0 if this equals to {@code otherBuffer}; a positive value - * if this is greater than {@code otherBuffer}. - * @exception ClassCastException if {@code otherBuffer} is not a short buffer. - * @since Android 1.0 */ - public int compareTo (ShortBuffer otherBuffer) { - int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); - int thisPos = position; - int otherPos = otherBuffer.position; - short thisByte, otherByte; - while (compareRemaining > 0) { - thisByte = get(thisPos); - otherByte = otherBuffer.get(otherPos); - if (thisByte != otherByte) { - return thisByte < otherByte ? -1 : 1; - } - thisPos++; - otherPos++; - compareRemaining--; - } - return remaining() - otherBuffer.remaining(); - } - - /** Returns a duplicated buffer that shares its content with this buffer. - *- * The duplicated buffer's position, limit, capacity and mark are the same as this buffer. The duplicated buffer's read-only - * property and byte order are the same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a duplicated buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer duplicate (); - - /** Checks whether this short buffer is equal to another object. - *- * If {@code other} is not a short buffer then {@code false} is returned. Two short buffers are equal if and only if their - * remaining shorts are exactly the same. Position, limit, capacity and mark are not considered. - *
- * - * @param other the object to compare with this short buffer. - * @return {@code true} if this short buffer is equal to {@code other}, {@code false} otherwise. - * @since Android 1.0 */ - public boolean equals (Object other) { - if (!(other instanceof ShortBuffer)) { - return false; - } - ShortBuffer otherBuffer = (ShortBuffer)other; - - if (remaining() != otherBuffer.remaining()) { - return false; - } - - int myPosition = position; - int otherPosition = otherBuffer.position; - boolean equalSoFar = true; - while (equalSoFar && (myPosition < limit)) { - equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); - } - - return equalSoFar; - } - - /** Returns the short at the current position and increases the position by 1. - * - * @return the short at the current position. - * @exception BufferUnderflowException if the position is equal or greater than limit. - * @since Android 1.0 */ - public abstract short get (); - - /** Reads shorts from the current position into the specified short array and increases the position by the number of shorts - * read. - *- * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. - *
- * - * @param dest the destination short array. - * @return this buffer. - * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ShortBuffer get (short[] dest) { - return get(dest, 0, dest.length); - } - - /** Reads shorts from the current position into the specified short array, starting from the specified offset, and increases the - * position by the number of shorts read. - * - * @param dest the target short array. - * @param off the offset of the short array, must not be negative and not greater than {@code dest.length}. - * @param len the number of shorts to read, must be no less than zero and not greater than {@code dest.length - off}. - * @return this buffer. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. - * @since Android 1.0 */ - public ShortBuffer get (short[] dest, int off, int len) { - int length = dest.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - if (len > remaining()) { - throw new BufferUnderflowException(); - } - for (int i = off; i < off + len; i++) { - dest[i] = get(); - } - return this; - } - - /** Returns the short at the specified index; the position is not changed. - * - * @param index the index, must not be negative and less than limit. - * @return a short at the specified index. - * @exception IndexOutOfBoundsException if index is invalid. - * @since Android 1.0 */ - public abstract short get (int index); - - /** Indicates whether this buffer is based on a short array and is read/write. - * - * @return {@code true} if this buffer is based on a short array and provides read/write access, {@code false} otherwise. - * @since Android 1.0 */ - public final boolean hasArray () { - return protectedHasArray(); - } - - /** Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash - * code. - * - * @return the hash code calculated from the remaining shorts. - * @since Android 1.0 */ - public int hashCode () { - int myPosition = position; - int hash = 0; - while (myPosition < limit) { - hash = hash + get(myPosition++); - } - return hash; - } - - /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it - * may not stay in the Java heap, so it is not affected by garbage collection. - *- * A short buffer is direct if it is based on a byte buffer and the byte buffer is direct. - *
- * - * @return {@code true} if this buffer is direct, {@code false} otherwise. - * @since Android 1.0 */ - public abstract boolean isDirect (); - - /** Returns the byte order used by this buffer when converting shorts from/to bytes. - *- * If this buffer is not based on a byte buffer, then always return the platform's native byte order. - *
- * - * @return the byte order used by this buffer when converting shorts from/to bytes. - * @since Android 1.0 */ - public abstract ByteOrder order (); - - /** Child class implements this method to realize {@code array()}. - * - * @return see {@code array()} */ - abstract short[] protectedArray (); - - /** Child class implements this method to realize {@code arrayOffset()}. - * - * @return see {@code arrayOffset()} */ - abstract int protectedArrayOffset (); - - /** Child class implements this method to realize {@code hasArray()}. - * - * @return see {@code hasArray()} */ - abstract boolean protectedHasArray (); - - /** Writes the given short to the current position and increases the position by 1. - * - * @param s the short to write. - * @return this buffer. - * @exception BufferOverflowException if position is equal or greater than limit. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer put (short s); - - /** Writes shorts from the given short array to the current position and increases the position by the number of shorts written. - *- * Calling this method has the same effect as {@code put(src, 0, src.length)}. - *
- * - * @param src the source short array. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public final ShortBuffer put (short[] src) { - return put(src, 0, src.length); - } - - /** Writes shorts from the given short array, starting from the specified offset, to the current position and increases the - * position by the number of shorts written. - * - * @param src the source short array. - * @param off the offset of short array, must not be negative and not greater than {@code src.length}. - * @param len the number of shorts to write, must be no less than zero and not greater than {@code src.length - off}. - * @return this buffer. - * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. - * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ShortBuffer put (short[] src, int off, int len) { - int length = src.length; - if (off < 0 || len < 0 || (long)off + (long)len > length) { - throw new IndexOutOfBoundsException(); - } - - if (len > remaining()) { - throw new BufferOverflowException(); - } - for (int i = off; i < off + len; i++) { - put(src[i]); - } - return this; - } - - /** Writes all the remaining shorts of the {@code src} short buffer to this buffer's current position, and increases both - * buffers' position by the number of shorts copied. - * - * @param src the source short buffer. - * @return this buffer. - * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. - * @exception IllegalArgumentException if {@code src} is this buffer. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public ShortBuffer put (ShortBuffer src) { - if (src == this) { - throw new IllegalArgumentException(); - } - if (src.remaining() > remaining()) { - throw new BufferOverflowException(); - } - short[] contents = new short[src.remaining()]; - src.get(contents); - put(contents); - return this; - } - - /** Writes a short to the specified index of this buffer; the position is not changed. - * - * @param index the index, must not be negative and less than the limit. - * @param s the short to write. - * @return this buffer. - * @exception IndexOutOfBoundsException if index is invalid. - * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer put (int index, short s); - - /** Returns a sliced buffer that shares its content with this buffer. - *- * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this - * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new - * buffer's read-only property and byte order are same as this buffer's. - *
- *- * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the - * other. The two buffer's position, limit and mark are independent. - *
- * - * @return a sliced buffer that shares its content with this buffer. - * @since Android 1.0 */ - public abstract ShortBuffer slice (); - - /** Returns a string representing the state of this short buffer. - * - * @return a string representing the state of this short buffer. - * @since Android 1.0 */ - public String toString () { - StringBuffer buf = new StringBuffer(); - buf.append(getClass().getName()); - buf.append(", status: capacity="); //$NON-NLS-1$ - buf.append(capacity()); - buf.append(" position="); //$NON-NLS-1$ - buf.append(position()); - buf.append(" limit="); //$NON-NLS-1$ - buf.append(limit()); - return buf.toString(); - } -} diff --git a/backends/gdx-backend-dragome/emu/java/nio/ShortToByteBufferAdapter.java b/backends/gdx-backend-dragome/emu/java/nio/ShortToByteBufferAdapter.java deleted file mode 100644 index 868072cd..00000000 --- a/backends/gdx-backend-dragome/emu/java/nio/ShortToByteBufferAdapter.java +++ /dev/null @@ -1,205 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.nio; - -//import org.apache.harmony.nio.internal.DirectBuffer; -//import org.apache.harmony.luni.platform.PlatformAddress; - -/** This class wraps a byte buffer to be a short buffer. - *- * Implementation notice: - *
The language codes are two-letter lowercase ISO language codes (such as "en") as defined by - * ISO 639-1. - * The country codes are two-letter uppercase ISO country codes (such as "US") as defined by - * ISO 3166-1. - * The variant codes are unspecified. - * - *
Note that Java uses several deprecated two-letter codes. The Hebrew ("he") language
- * code is rewritten as "iw", Indonesian ("id") as "in", and Yiddish ("yi") as "ji". This
- * rewriting happens even if you construct your own {@code Locale} object, not just for
- * instances returned by the various lookup methods.
- *
- * Available locales
- *
This class' constructors do no error checking. You can create a {@code Locale} for languages - * and countries that don't exist, and you can create instances for combinations that don't - * exist (such as "de_US" for "German as spoken in the US"). - * - *
Note that locale data is not necessarily available for any of the locales pre-defined as - * constants in this class except for en_US, which is the only locale Java guarantees is always - * available. - * - *
It is also a mistake to assume that all devices have the same locales available. - * A device sold in the US will almost certainly support en_US and es_US, but not necessarily - * any locales with the same language but different countries (such as en_GB or es_ES), - * nor any locales for other languages (such as de_DE). The opposite may well be true for a device - * sold in Europe. - * - *
You can use {@link Locale#getDefault} to get an appropriate locale for the user of the
- * device you're running on, or {@link Locale#getAvailableLocales} to get a list of all the locales
- * available on the device you're running on.
- *
- * Locale data
- *
Note that locale data comes solely from ICU. User-supplied locale service providers (using - * the {@code java.text.spi} or {@code java.util.spi} mechanisms) are not supported. - * - *
Here are the versions of ICU (and the corresponding CLDR and Unicode versions) used in - * various Android releases: - *
Cupcake/Donut/Eclair | ICU 3.8 | CLDR 1.5 | Unicode 5.0 |
Froyo | ICU 4.2 | CLDR 1.7 | Unicode 5.1 |
Gingerbread/Honeycomb | ICU 4.4 | CLDR 1.8 | Unicode 5.2 |
Ice Cream Sandwich | ICU 4.6 | CLDR 1.9 | Unicode 6.0 |
Jelly Bean | ICU 4.8 | CLDR 2.0 | Unicode 6.0 |
Jelly Bean MR2 | ICU 50 | CLDR 22.1 | Unicode 6.2 |
Note that there are many convenience methods that automatically use the default locale, but - * using them may lead to subtle bugs. - * - *
The default locale is appropriate for tasks that involve presenting data to the user. In - * this case, you want to use the user's date/time formats, number - * formats, rules for conversion to lowercase, and so on. In this case, it's safe to use the - * convenience methods. - * - *
The default locale is not appropriate for machine-readable output. The best choice - * there is usually {@code Locale.US} – this locale is guaranteed to be available on all - * devices, and the fact that it has no surprising special cases and is frequently used (especially - * for computer-computer communication) means that it tends to be the most efficient choice too. - * - *
A common mistake is to implicitly use the default locale when producing output meant to be - * machine-readable. This tends to work on the developer's test devices (especially because so many - * developers use en_US), but fails when run on a device whose user is in a more complex locale. - * - *
For example, if you're formatting integers some locales will use non-ASCII decimal - * digits. As another example, if you're formatting floating-point numbers some locales will use - * {@code ','} as the decimal point and {@code '.'} for digit grouping. That's correct for - * human-readable output, but likely to cause problems if presented to another - * computer ({@link Double#parseDouble} can't parse such a number, for example). - * You should also be wary of the {@link String#toLowerCase} and - * {@link String#toUpperCase} overloads that don't take a {@code Locale}: in Turkey, for example, - * the characters {@code 'i'} and {@code 'I'} won't be converted to {@code 'I'} and {@code 'i'}. - * This is the correct behavior for Turkish text (such as user input), but inappropriate for, say, - * HTTP headers. - */ -public final class Locale implements Cloneable, Serializable { - - private static final long serialVersionUID = 9149081749638150636L; - - /** - * Locale constant for en_CA. - */ - public static final Locale CANADA = new Locale(true, "en", "CA"); - - /** - * Locale constant for fr_CA. - */ - public static final Locale CANADA_FRENCH = new Locale(true, "fr", "CA"); - - /** - * Locale constant for zh_CN. - */ - public static final Locale CHINA = new Locale(true, "zh", "CN"); - - /** - * Locale constant for zh. - */ - public static final Locale CHINESE = new Locale(true, "zh", ""); - - /** - * Locale constant for en. - */ - public static final Locale ENGLISH = new Locale(true, "en", ""); - - /** - * Locale constant for fr_FR. - */ - public static final Locale FRANCE = new Locale(true, "fr", "FR"); - - /** - * Locale constant for fr. - */ - public static final Locale FRENCH = new Locale(true, "fr", ""); - - /** - * Locale constant for de. - */ - public static final Locale GERMAN = new Locale(true, "de", ""); - - /** - * Locale constant for de_DE. - */ - public static final Locale GERMANY = new Locale(true, "de", "DE"); - - /** - * Locale constant for it. - */ - public static final Locale ITALIAN = new Locale(true, "it", ""); - - /** - * Locale constant for it_IT. - */ - public static final Locale ITALY = new Locale(true, "it", "IT"); - - /** - * Locale constant for ja_JP. - */ - public static final Locale JAPAN = new Locale(true, "ja", "JP"); - - /** - * Locale constant for ja. - */ - public static final Locale JAPANESE = new Locale(true, "ja", ""); - - /** - * Locale constant for ko_KR. - */ - public static final Locale KOREA = new Locale(true, "ko", "KR"); - - /** - * Locale constant for ko. - */ - public static final Locale KOREAN = new Locale(true, "ko", ""); - - /** - * Locale constant for zh_CN. - */ - public static final Locale PRC = new Locale(true, "zh", "CN"); - - /** - * Locale constant for the root locale. The root locale has an empty language, - * country, and variant. - * - * @since 1.6 - */ - public static final Locale ROOT = new Locale(true, "", ""); - - /** - * Locale constant for zh_CN. - */ - public static final Locale SIMPLIFIED_CHINESE = new Locale(true, "zh", "CN"); - - /** - * Locale constant for zh_TW. - */ - public static final Locale TAIWAN = new Locale(true, "zh", "TW"); - - /** - * Locale constant for zh_TW. - */ - public static final Locale TRADITIONAL_CHINESE = new Locale(true, "zh", "TW"); - - /** - * Locale constant for en_GB. - */ - public static final Locale UK = new Locale(true, "en", "GB"); - - /** - * Locale constant for en_US. - */ - public static final Locale US = new Locale(true, "en", "US"); - -// /** -// * The current default locale. It is temporarily assigned to US because we -// * need a default locale to lookup the real default locale. -// */ - private static Locale defaultLocale = US; - -// static { -// String language = System.getProperty("user.language", "en"); -// String region = System.getProperty("user.region", "US"); -// String variant = System.getProperty("user.variant", ""); -// defaultLocale = new Locale(language, region, variant); -// } - - private transient String countryCode; - private transient String languageCode; - private transient String variantCode; - private transient String cachedToStringResult; - - /** - * There's a circular dependency between toLowerCase/toUpperCase and - * Locale.US. Work around this by avoiding these methods when constructing - * the built-in locales. - * - * @param unused required for this constructor to have a unique signature - */ - private Locale(boolean unused, String lowerCaseLanguageCode, String upperCaseCountryCode) { - this.languageCode = lowerCaseLanguageCode; - this.countryCode = upperCaseCountryCode; - this.variantCode = ""; - } - - /** - * Constructs a new {@code Locale} using the specified language. - */ - public Locale(String language) { - this(language, "", ""); - } - - /** - * Constructs a new {@code Locale} using the specified language and country codes. - */ - public Locale(String language, String country) { - this(language, country, ""); - } - - /** - * Constructs a new {@code Locale} using the specified language, country, - * and variant codes. - */ - public Locale(String language, String country, String variant) { - if (language == null || country == null || variant == null) { - throw new NullPointerException("language=" + language + - ",country=" + country + - ",variant=" + variant); - } - if (language.isEmpty() && country.isEmpty()) { - languageCode = ""; - countryCode = ""; - variantCode = variant; - return; - } - -// languageCode = language.toLowerCase(Locale.US); // not supported by GWT - languageCode = language.toLowerCase(); - // Map new language codes to the obsolete language - // codes so the correct resource bundles will be used. - if (languageCode.equals("he")) { - languageCode = "iw"; - } else if (languageCode.equals("id")) { - languageCode = "in"; - } else if (languageCode.equals("yi")) { - languageCode = "ji"; - } - -// countryCode = country.toUpperCase(Locale.US); // not supported by GWT - countryCode = country.toUpperCase(); - - // Work around for be compatible with RI - variantCode = variant; - } - -// @Override public Object clone() { -// try { -// return super.clone(); -// } catch (CloneNotSupportedException e) { -// throw new AssertionError(e); -// } -// } - - /** - * Returns true if {@code object} is a locale with the same language, - * country and variant. - */ - @Override public boolean equals(Object object) { - if (object == this) { - return true; - } - if (object instanceof Locale) { - Locale o = (Locale) object; - return languageCode.equals(o.languageCode) - && countryCode.equals(o.countryCode) - && variantCode.equals(o.variantCode); - } - return false; - } - -// /** -// * Returns the system's installed locales. This array always includes {@code -// * Locale.US}, and usually several others. Most locale-sensitive classes -// * offer their own {@code getAvailableLocales} method, which should be -// * preferred over this general purpose method. -// * -// * @see java.text.BreakIterator#getAvailableLocales() -// * @see java.text.Collator#getAvailableLocales() -// * @see java.text.DateFormat#getAvailableLocales() -// * @see java.text.DateFormatSymbols#getAvailableLocales() -// * @see java.text.DecimalFormatSymbols#getAvailableLocales() -// * @see java.text.NumberFormat#getAvailableLocales() -// * @see java.util.Calendar#getAvailableLocales() -// */ -// public static Locale[] getAvailableLocales() { -// return ICU.getAvailableLocales(); -// } - - /** - * Returns the country code for this locale, or {@code ""} if this locale - * doesn't correspond to a specific country. - */ - public String getCountry() { - return countryCode; - } - - /** - * Returns the user's preferred locale. This may have been overridden for - * this process with {@link #setDefault}. - * - *
Since the user's locale changes dynamically, avoid caching this value. - * Instead, use this method to look it up for each use. - */ - public static Locale getDefault() { - return defaultLocale; - } - -// /** -// * Equivalent to {@code getDisplayCountry(Locale.getDefault())}. -// */ -// public final String getDisplayCountry() { -// return getDisplayCountry(getDefault()); -// } -// -// /** -// * Returns the name of this locale's country, localized to {@code locale}. -// * Returns the empty string if this locale does not correspond to a specific -// * country. -// */ -// public String getDisplayCountry(Locale locale) { -// if (countryCode.isEmpty()) { -// return ""; -// } -// String result = ICU.getDisplayCountryNative(toString(), locale.toString()); -// if (result == null) { // TODO: do we need to do this, or does ICU do it for us? -// result = ICU.getDisplayCountryNative(toString(), Locale.getDefault().toString()); -// } -// return result; -// } -// -// /** -// * Equivalent to {@code getDisplayLanguage(Locale.getDefault())}. -// */ -// public final String getDisplayLanguage() { -// return getDisplayLanguage(getDefault()); -// } -// -// /** -// * Returns the name of this locale's language, localized to {@code locale}. -// * If the language name is unknown, the language code is returned. -// */ -// public String getDisplayLanguage(Locale locale) { -// if (languageCode.isEmpty()) { -// return ""; -// } -// -// // http://b/8049507 --- frameworks/base should use fil_PH instead of tl_PH. -// // Until then, we're stuck covering their tracks, making it look like they're -// // using "fil" when they're not. -// String localeString = toString(); -// if (languageCode.equals("tl")) { -// localeString = toNewString("fil", countryCode, variantCode); -// } -// -// String result = ICU.getDisplayLanguageNative(localeString, locale.toString()); -// if (result == null) { // TODO: do we need to do this, or does ICU do it for us? -// result = ICU.getDisplayLanguageNative(localeString, Locale.getDefault().toString()); -// } -// return result; -// } -// -// /** -// * Equivalent to {@code getDisplayName(Locale.getDefault())}. -// */ -// public final String getDisplayName() { -// return getDisplayName(getDefault()); -// } -// -// /** -// * Returns this locale's language name, country name, and variant, localized -// * to {@code locale}. The exact output form depends on whether this locale -// * corresponds to a specific language, country and variant. -// * -// *
For example: -// *
Examples: "en", "en_US", "_US", "en__POSIX", "en_US_POSIX" - */ - @Override - public final String toString() { - String result = cachedToStringResult; - if (result == null) { - result = cachedToStringResult = toNewString(languageCode, countryCode, variantCode); - } - return result; - } - - private static String toNewString(String languageCode, String countryCode, String variantCode) { - // The string form of a locale that only has a variant is the empty string. - if (languageCode.length() == 0 && countryCode.length() == 0) { - return ""; - } - // Otherwise, the output format is "ll_cc_variant", where language and country are always - // two letters, but the variant is an arbitrary length. A size of 11 characters has room - // for "en_US_POSIX", the largest "common" value. (In practice, the string form is almost - // always 5 characters: "ll_cc".) - StringBuilder result = new StringBuilder(11); - result.append(languageCode); - if (countryCode.length() > 0 || variantCode.length() > 0) { - result.append('_'); - } - result.append(countryCode); - if (variantCode.length() > 0) { - result.append('_'); - } - result.append(variantCode); - return result.toString(); - } - -// private static final ObjectStreamField[] serialPersistentFields = { -// new ObjectStreamField("country", String.class), -// new ObjectStreamField("hashcode", int.class), -// new ObjectStreamField("language", String.class), -// new ObjectStreamField("variant", String.class), -// }; -// -// private void writeObject(ObjectOutputStream stream) throws IOException { -// ObjectOutputStream.PutField fields = stream.putFields(); -// fields.put("country", countryCode); -// fields.put("hashcode", -1); -// fields.put("language", languageCode); -// fields.put("variant", variantCode); -// stream.writeFields(); -// } -// -// private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { -// ObjectInputStream.GetField fields = stream.readFields(); -// countryCode = (String) fields.get("country", ""); -// languageCode = (String) fields.get("language", ""); -// variantCode = (String) fields.get("variant", ""); -// } -} diff --git a/backends/gdx-backend-dragome/emu/java/util/StringTokenizer.java b/backends/gdx-backend-dragome/emu/java/util/StringTokenizer.java deleted file mode 100644 index e6686e8b..00000000 --- a/backends/gdx-backend-dragome/emu/java/util/StringTokenizer.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package java.util; - -/** - * Breaks a string into tokens; new code should probably use {@link String#split}. - * - *
- *- * - * @since 1.0 - */ -public class StringTokenizer implements Enumeration- * // Legacy code: - * StringTokenizer st = new StringTokenizer("a:b:c", ":"); - * while (st.hasMoreTokens()) { - * System.err.println(st.nextToken()); - * } - * - * // New code: - * for (String token : "a:b:c".split(":")) { - * System.err.println(token); - * } - *- *