PageRenderTime 41ms CodeModel.GetById 36ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/name/carter/mark/flex/project/mdoc/TaggableMNode.as

http://transcriptstudio4isha.googlecode.com/
ActionScript | 62 lines | 42 code | 8 blank | 12 comment | 9 complexity | 8e77e8d77c6cb9aa23ba91a67a29a9e3 MD5 | raw file
 1package name.carter.mark.flex.project.mdoc
 2{
 3	import name.carter.mark.flex.util.XMLUtils;
 4	
 5	public class TaggableMNode extends MNode
 6	{
 7		public function TaggableMNode(element:XML, xmlBasedDoc:MDocument)
 8		{
 9			super(element, xmlBasedDoc);
10		}
11		
12		/*public function get tags():Array
13		{
14			var result:Array = new Array();
15			for each (var tagElement:XML in nodeElement.tag) {
16				var tag:XMLBasedMTag = new XMLBasedMTag(tagElement);
17				result.push(tag);
18			}
19			return result;
20		}*/
21		
22		/**
23		 * returns an array of string values.
24		 */
25		internal function getTags(tagType:String = null):Array {
26			var result:Array = new Array();
27			for each (var tagElement:XML in nodeElement.tag) {
28				var tag:MTag = new XMLBasedMTag(tagElement);
29				if (tagType == null || tag.type == tagType) {
30					result.push(tag);
31				}
32			}
33			return result;
34		}
35		
36		internal function getTagValues(tagType:String):Array {
37			var tags:Array = getTags(tagType);
38			return tags.map(function(tag:MTag, index:int, array:Array):String {
39				return tag.value;
40			});
41		}
42		
43		internal function addTag(tagType:String, value:String):XMLBasedMTag {
44			modified = true;
45			var result:XMLBasedMTag = XMLBasedMTag.addNewTag(this, tagType, value);
46			return result;
47		}
48		
49		public function removeAllTags(type:String = null):void {
50			modified = true;
51			for each (var tag:MTag in getTags(type)) {
52				tag.remove();
53			}
54		}
55		
56		public function removeAllNotesAndSummaries():void {
57			modified = true;
58			XMLUtils.removeAllElements(nodeElement.*.(localName() == MSuperNodeProperties.NOTES_PROP_NAME || localName() == MSuperNodeProperties.SUMMARY_PROP_NAME));
59		}
60		
61	}
62}