diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java index aaeddc3a6bd..51a3ab53bce 100644 --- a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java +++ b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRanges.java @@ -23,14 +23,36 @@ package org.mozilla.pluglet.mozilla; /** * This interface is for setting up a range of bytes. */ -public interface ByteRanges { +public class ByteRanges { /** * Sets a range of bytes, given an offset and a length. If offset is negative, * then the offset is from the end.
- * @param offset This is the offset for the range of bytes -- from the + * @param offset This is the offset for the range of bytes - from the * beginning if offset is positive, from the end if offset is negative.
* @param length This is the length of the range of bytes; i.e., the number * of bytes. */ - public void addRange(int offset, int length); + public void addRange(int off, int len) { + if (current >= offset.length) { + int tmpOffset[] = new int[offset.length+STEP]; + int tmpLength[] = new int[offset.length+STEP]; + System.arraycopy(offset,0,tmpOffset,0,offset.length); + System.arraycopy(length,0,tmpLength,0,length.length); + offset = tmpOffset; + length = tmpLength; + } + offset[current] = off; + length[current] = len; + current++; + } + public ByteRanges() { + offset = new int[STEP]; + length = new int[STEP]; + } + private int offset[]; + private int length[]; + //this is the index for next available free cell in the array + private int current = 0; + //size increment for offset and length arrays + private final static int STEP = 10; } diff --git a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRangesImpl.java b/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRangesImpl.java deleted file mode 100644 index 1709c672e05..00000000000 --- a/mozilla/java/plugins/classes/org/mozilla/pluglet/mozilla/ByteRangesImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Sun Microsystems, - * Inc. Portions created by Sun are - * Copyright (C) 1999 Sun Microsystems, Inc. All - * Rights Reserved. - * - * Contributor(s): - */ -package org.mozilla.pluglet.mozilla; - -class ByteRangesImpl implements ByteRanges { - //why not [][] ? Because it is simpler & faster from jni - private int offset[]; - private int length[]; - //this is the index for next available free cell in the array - private int current = 0; - //size increment for offset and length arrays - private final static int STEP = 10; - ByteRangesImpl() { - offset = new int[STEP]; - length = new int[STEP]; - } - public void addRange(int off, int len) { - if (current >= offset.length) { - int tmpOffset[] = new int[offset.length+STEP]; - int tmpLength[] = new int[offset.length+STEP]; - System.arraycopy(offset,0,tmpOffset,0,offset.length); - System.arraycopy(length,0,tmpLength,0,length.length); - offset = tmpOffset; - length = tmpLength; - } - offset[current] = off; - length[current] = len; - current++; - } - -} diff --git a/mozilla/java/plugins/jni/ByteRanges.cpp b/mozilla/java/plugins/jni/ByteRanges.cpp index 6ddf40fe9f9..103397ded15 100644 --- a/mozilla/java/plugins/jni/ByteRanges.cpp +++ b/mozilla/java/plugins/jni/ByteRanges.cpp @@ -88,7 +88,7 @@ void ByteRanges::FreeByteRanges(nsByteRange * ranges) { } void ByteRanges::Initialize(JNIEnv *env) { - jclass clazz = env->FindClass("org/mozilla/pluglet/mozilla/ByteRangesImpl"); + jclass clazz = env->FindClass("org/mozilla/pluglet/mozilla/ByteRanges"); if(!clazz) { env->ExceptionDescribe(); return;