accessible parent chunk from Value

This commit is contained in:
REAndroid 2023-03-26 11:18:07 -04:00
parent a92e929812
commit 63478aaa1b
6 changed files with 45 additions and 0 deletions

View File

@ -170,6 +170,10 @@ package com.reandroid.arsc.chunk;
public SpecStringPool getSpecStringPool(){
return mSpecStringPool;
}
@Override
public TableBlock getMainChunk(){
return getTableBlock();
}
public PackageBody getPackageBody() {
return mBody;
}

View File

@ -19,4 +19,5 @@ import com.reandroid.arsc.pool.StringPool;
public interface ParentChunk {
public StringPool<?> getSpecStringPool();
public MainChunk getMainChunk();
}

View File

@ -237,6 +237,15 @@
setValueStringReference(-1);
}
}
@Override
public ResXmlDocument getParentChunk() {
ResXmlElement element = getParentResXmlElement();
if(element!=null){
return element.getParentDocument();
}
return null;
}
private void linkNameId(){
ResXmlID xmlID = getResXmlID();
if(xmlID==null){

View File

@ -15,6 +15,8 @@
*/
package com.reandroid.arsc.value;
import com.reandroid.arsc.chunk.PackageBlock;
public class ResValue extends ValueItem {
public ResValue() {
super(8, OFFSET_SIZE);
@ -24,5 +26,14 @@ package com.reandroid.arsc.value;
return getParent(Entry.class);
}
@Override
public PackageBlock getParentChunk(){
Entry entry = getEntry();
if(entry != null){
return entry.getPackageBlock();
}
return null;
}
private static final int OFFSET_SIZE = 0;
}

View File

@ -16,6 +16,7 @@
package com.reandroid.arsc.value;
import com.reandroid.arsc.base.Block;
import com.reandroid.arsc.chunk.PackageBlock;
import com.reandroid.json.JSONObject;
public class ResValueMap extends ValueItem{
@ -27,6 +28,14 @@ public class ResValueMap extends ValueItem{
public Entry getEntry(){
return getParent(Entry.class);
}
@Override
public PackageBlock getParentChunk(){
Entry entry = getEntry();
if(entry!=null){
return entry.getPackageBlock();
}
return null;
}
public ResTableMapEntry getParentMapEntry(){
Block parent=getParent();

View File

@ -15,9 +15,20 @@
*/
package com.reandroid.arsc.value;
import com.reandroid.arsc.chunk.MainChunk;
import com.reandroid.arsc.chunk.ParentChunk;
public interface Value {
void setValueType(ValueType valueType);
ValueType getValueType();
int getData();
void setData(int data);
ParentChunk getParentChunk();
default MainChunk getMainChunk(){
ParentChunk parentChunk = getParentChunk();
if(parentChunk!=null){
return parentChunk.getMainChunk();
}
return null;
}
}