ARSCLib/src/main/java/com/reandroid/arsc/item/TableString.java
2023-02-13 11:38:58 -05:00

52 lines
1.7 KiB
Java
Executable File

/*
* 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 com.reandroid.arsc.value.Entry;
import com.reandroid.arsc.value.ResValueMap;
import com.reandroid.arsc.value.ValueItem;
import java.util.ArrayList;
import java.util.List;
public class TableString extends StringItem {
public TableString(boolean utf8) {
super(utf8);
}
public List<Entry> listReferencedEntries(boolean ignoreBagEntries){
List<Entry> results=new ArrayList<>();
for(ReferenceItem ref:getReferencedList()){
if(!(ref instanceof ReferenceBlock)){
continue;
}
ValueItem valueItem = (ValueItem) ((ReferenceBlock)ref).getBlock();
if(valueItem ==null){
continue;
}
if(ignoreBagEntries && (valueItem instanceof ResValueMap)){
continue;
}
results.add(valueItem.getParentEntry());
}
return results;
}
@Override
public String toString(){
List<ReferenceItem> refList = getReferencedList();
return "USED BY="+refList.size()+"{"+super.toString()+"}";
}
}