
com.reandroid.arsc.item.IntegerArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ARSCLib Show documentation
Show all versions of ARSCLib Show documentation
Android binary resources read/write library
/*
* Copyright (C) 2022 github.com/REAndroid
*
* 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 com.reandroid.arsc.item;
import java.util.AbstractList;
import java.util.List;
public class IntegerArray extends BlockItem {
public IntegerArray() {
super(0);
}
public final boolean contains(int value){
int s=size();
for(int i=0;i toList(){
return new AbstractList() {
@Override
public Integer get(int i) {
return IntegerArray.this.get(i);
}
@Override
public int size() {
return IntegerArray.this.size();
}
};
}
public final int[] toArray(){
int s=size();
int[] result=new int[s];
for(int i=0;i=s){
return;
}
setSize(s);
}
public final void setSize(int s){
if(s<0){
s=0;
}
int len=s*4;
setBytesLength(len);
}
public Integer get(int index){
if(index<0 || index>=size()){
return null;
}
int i=index*4;
byte[] bts = getBytesInternal();
return bts[i] & 0xff |
(bts[i+1] & 0xff) << 8 |
(bts[i+2] & 0xff) << 16 |
(bts[i+3] & 0xff) << 24;
}
public int getAt(int index){
int i=index*4;
byte[] bts = getBytesInternal();
return bts[i] & 0xff |
(bts[i+1] & 0xff) << 8 |
(bts[i+2] & 0xff) << 16 |
(bts[i+3] & 0xff) << 24;
}
public final int size(){
return getBytesLength()/4;
}
public final void put(int index, int value){
int i=index*4;
byte[] bts = getBytesInternal();
bts[i+3]= (byte) (value >>> 24 & 0xff);
bts[i+2]= (byte) (value >>> 16 & 0xff);
bts[i+1]= (byte) (value >>> 8 & 0xff);
bts[i]= (byte) (value & 0xff);
}
@Override
public String toString(){
return "size="+size();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy