public Object clone() { XMLTag ThisClone = new XMLTag(TagName, TagValue, IsTemporary); ThisClone.AttributeList = (HashMap) AttributeList.clone(); for (int i = 0; i < ChildTags.size(); i++) { XMLTag TagToClone = (XMLTag) ChildTags.get(i); ThisClone.addTag((XMLTag) TagToClone.clone()); } return ThisClone; }
/** * Constructor to create a tag with a value as the child of another tag, which can be set as * temporary. * * <p>If a tag is deemed temporary then it will occur in all searches etc. but when the tag is * output (with writeTag() or as part of an XMLFile) the tag will not be included. * * @param TagName The name of the new tag. * @param TagValue The value of the new tag. * @param ParentTag The tag which will be the parent of the new tag. * @param IsTemporary <CODE>true</CODE> if the tag is temporary, <CODE>false</CODE> if not. */ public XMLTag(String _TagName, String _TagValue, XMLTag _ParentTag, boolean _IsTemporary) { this.ParentTag = _ParentTag; this.TagName = _TagName; this.TagValue = _TagValue; this.IsTemporary = _IsTemporary; if (ParentTag != null) { ParentTag.addTag(this); } }
/** * Replaces <CODE>ParentTag.getTag(OldTagName, OccurrenceNumber)</CODE> with this tag. If not * enough tags are found, then this tag is just added to ParentTag. * * @param ParentTag The parent tag to search from. * @param OldTagName The path to the tag to be replaced. * @param OccurrenceNumber The occurrence number of the path in OldTagName to be replaced. * @return The tag that has been replaced if one existed, else null. */ public XMLTag replace(XMLTag _ParentTag, String OldTagName, int OccurrenceNumber) { XMLTag OldTag = _ParentTag.getTag(OldTagName, OccurrenceNumber); if (OldTag != null) { // OldTag.removeTagFromParent().addTag(this); _ParentTag.exchangeChild(OldTag, this); } else { _ParentTag.addTag(this); } return OldTag; }
public static void sortTagList(XMLTag list, String tagName, String criteria) { XMLTag[] unorderedVars = list.getTags(tagName); XMLTag[] orderedVars = XMLTag.sortTags(unorderedVars, criteria); for (int k = 0; k < unorderedVars.length; k++) unorderedVars[k].removeFromParent(); for (int k = 0; k < orderedVars.length; k++) list.addTag(orderedVars[k]); }
/** * Makes NewParent the parent tag of this. * * @param NewParent The tag to add this one to. * @return NewParent. */ public XMLTag addToTag(XMLTag NewParent) { NewParent.addTag(this); return NewParent; }