Simplify create root ResXmlElement

This commit is contained in:
REAndroid 2022-12-25 15:38:31 -05:00
parent 6abaaebdb4
commit c288c50c89
3 changed files with 23 additions and 1 deletions

View File

@ -48,6 +48,18 @@ public class ResXmlBlock extends BaseChunk implements JSONConvert<JSONObject> {
addChild(mResXmlIDMap);
addChild(mResXmlElementContainer);
}
public ResXmlElement createRootElement(String tag){
int lineNo=1;
ResXmlElement resXmlElement=new ResXmlElement();
resXmlElement.newStartElement(lineNo);
setResXmlElement(resXmlElement);
if(tag!=null){
resXmlElement.setTag(tag);
}
return resXmlElement;
}
void linkStringReferences(){
ResXmlElement element=getResXmlElement();
if(element!=null){

View File

@ -55,6 +55,9 @@ import java.util.*;
addChild(4, mEndElementContainer);
addChild(5, mEndNamespaceList);
}
public ResXmlAttribute newAttribute(){
return getStartElement().newAttribute();
}
Set<ResXmlString> clearStringReferences(){
Set<ResXmlString> results=new HashSet<>();
for(ResXmlStartNamespace startNamespace:getStartNamespaceList()){
@ -229,6 +232,9 @@ import java.util.*;
public void addElement(ResXmlElement element){
mBody.add(element);
}
public boolean removeAttribute(ResXmlAttribute resXmlAttribute){
return getStartElement().getResXmlAttributeArray().remove(resXmlAttribute);
}
public boolean removeElement(ResXmlElement element){
if(element.getParent()!=null){
// TODO: Find a way to remove properly from StringPool
@ -330,7 +336,7 @@ import java.util.*;
mEndNamespaceList.add(item);
}
private ResXmlStartElement newStartElement(int lineNo){
ResXmlStartElement newStartElement(int lineNo){
ResXmlStartElement startElement=new ResXmlStartElement();
setStartElement(startElement);

View File

@ -50,6 +50,10 @@ import java.util.Set;
addChild(mStyleAttributePosition);
addChild(mAttributeArray);
}
public ResXmlAttribute newAttribute(){
ResXmlAttributeArray attributeArray = getResXmlAttributeArray();
return attributeArray.createNext();
}
@Override
void linkStringReferences(){
super.linkStringReferences();